1#@if IsHPCGAP 2gap> START_TEST("stdtasks.tst"); 3 4# 5gap> task := RunTask(x -> SortedList(x), [3,2,1]);; 6gap> WaitTask(task); 7gap> TaskResult(task); 8[ 1, 2, 3 ] 9 10# 11gap> task := RunTask(x -> SortedList(x), [3,2,1]);; 12gap> TaskResult(task); 13[ 1, 2, 3 ] 14 15# 16gap> task1 := RunTask(Product, [1..5000]);; 17gap> task2 := RunTask(Product, [5001..10000]);; 18gap> TaskResult(task1) * TaskResult(task2) = Factorial(10000); 19true 20 21# 22gap> task1 := DelayTask(Product, [1..5000]);; 23gap> task2 := DelayTask(Product, [5001..10000]);; 24gap> WaitTask(task1, task2); 25gap> TaskResult(task1) * TaskResult(task2) = Factorial(10000); 26true 27 28# 29gap> task := ImmediateTask(x -> SortedList(x), [3,2,1]);; 30gap> TaskResult(task); 31[ 1, 2, 3 ] 32 33# 34gap> t1 := RunTask(x->x*x, 3);; 35gap> t2 := RunTask(x->x*x, 4);; 36gap> t := ScheduleTask([t1, t2], function() 37> return TaskResult(t1) + TaskResult(t2); 38> end);; 39gap> TaskResult(t); 4025 41 42# 43gap> task1 := DelayTask(SortedList, [3,2,1]);; 44gap> task2 := DelayTask(SortedList, [2^15, 2^15-1 .. 1]);; 45gap> WaitAnyTask(task1, task2) in [1, 2]; 46true 47gap> WaitTasks(task1, task2); 48gap> TaskResult(task1); 49[ 1, 2, 3 ] 50gap> TaskResult(task2) = [1..2^15]; 51true 52 53# 54gap> task1 := DelayTask(MicroSleep, 10000);; 55gap> task2 := DelayTask(MicroSleep, 50000);; 56gap> WaitAnyTask(task1, task2) in [1,2]; 57true 58gap> WaitTasks(task1, task2); 59gap> WaitAnyTask(task1, task2); 601 61gap> task1 := DelayTask(MicroSleep, 50000);; 62gap> task2 := DelayTask(MicroSleep, 10000);; 63gap> WaitAnyTask(task1, task2) in [1,2]; 64true 65gap> WaitTasks(task1, task2); 66gap> WaitAnyTask(task1, task2); 671 68 69# 70gap> task := RunTask(function() 71> while true do 72> OnTaskCancellation(function() return 314; end); 73> od; 74> end);; 75gap> CancelTask(task); 76gap> TaskResult(task); 77314 78 79# 80gap> m := NewMilestone();; 81gap> IsMilestoneAchieved(m); 82false 83gap> AchieveMilestone(m); 84gap> IsMilestoneAchieved(m); 85true 86 87# 88gap> m := NewMilestone([1,2]);; 89gap> ContributeToMilestone(m, 1); 90gap> IsMilestoneAchieved(m); 91false 92gap> ContributeToMilestone(m, 2); 93gap> IsMilestoneAchieved(m); 94true 95 96# 97gap> STOP_TEST( "stdtasks.tst", 1 ); 98#@fi 99