aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_scheduler.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-04-19 12:07:05 +0000
committerChristian Grothoff <christian@grothoff.org>2012-04-19 12:07:05 +0000
commitb272a833ee57cad630ecbcce1aab366777042dd9 (patch)
tree9a6057f81afe36db736b4911a85c0b94538c1f53 /src/util/test_scheduler.c
parent50c4e060fc721dfe2af9115639a4d47e88e04f00 (diff)
downloadgnunet-b272a833ee57cad630ecbcce1aab366777042dd9.tar.gz
gnunet-b272a833ee57cad630ecbcce1aab366777042dd9.zip
-fixing #2274 -- eliminating GNUNET_SCHEDULER_add_after
Diffstat (limited to 'src/util/test_scheduler.c')
-rw-r--r--src/util/test_scheduler.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c
index 01982ee8b..9832ade6f 100644
--- a/src/util/test_scheduler.c
+++ b/src/util/test_scheduler.c
@@ -30,37 +30,25 @@
30#define VERBOSE GNUNET_NO 30#define VERBOSE GNUNET_NO
31 31
32static void 32static void
33task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 33task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
34{ 34{
35 int *ok = cls; 35 int *ok = cls;
36 36
37 /* t4 should be ready (albeit with lower priority) */ 37 /* t3 should be ready (albeit with lower priority) */
38 GNUNET_assert (1 == 38 GNUNET_assert (1 ==
39 GNUNET_SCHEDULER_get_load (GNUNET_SCHEDULER_PRIORITY_COUNT)); 39 GNUNET_SCHEDULER_get_load (GNUNET_SCHEDULER_PRIORITY_COUNT));
40 GNUNET_assert (3 == *ok);
41 (*ok) = 4;
42}
43
44
45static void
46task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
47{
48 int *ok = cls;
49
50 GNUNET_assert (2 == *ok); 40 GNUNET_assert (2 == *ok);
51 (*ok) = 3; 41 (*ok) = 3;
52 /* t3 will go before t4: higher priority */
53 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &task3,
54 cls);
55} 42}
56 43
44
57static void 45static void
58task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 46task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
59{ 47{
60 int *ok = cls; 48 int *ok = cls;
61 49
62 GNUNET_assert (4 == *ok); 50 GNUNET_assert (3 == *ok);
63 (*ok) = 5; 51 (*ok) = 4;
64} 52}
65 53
66struct GNUNET_DISK_PipeHandle *p; 54struct GNUNET_DISK_PipeHandle *p;
@@ -113,11 +101,11 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
113 101
114 102
115static void 103static void
116task5 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 104task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
117{ 105{
118 int *ok = cls; 106 int *ok = cls;
119 107
120 GNUNET_assert (5 == *ok); 108 GNUNET_assert (4 == *ok);
121 (*ok) = 6; 109 (*ok) = 6;
122 p = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO); 110 p = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_NO);
123 GNUNET_assert (NULL != p); 111 GNUNET_assert (NULL != p);
@@ -134,17 +122,13 @@ static void
134task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 122task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
135{ 123{
136 int *ok = cls; 124 int *ok = cls;
137 GNUNET_SCHEDULER_TaskIdentifier t2;
138 GNUNET_SCHEDULER_TaskIdentifier t4;
139 125
140 GNUNET_assert (1 == *ok); 126 GNUNET_assert (1 == *ok);
141 (*ok) = 2; 127 (*ok) = 2;
142 /* t2 will go first -- prereq for all */ 128 GNUNET_SCHEDULER_add_now (&task3, cls);
143 t2 = GNUNET_SCHEDULER_add_after (GNUNET_SCHEDULER_NO_TASK, &task2, cls); 129 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, &task2,
144 /* t4 will go after t2 ('add after') and after t3 (priority) */ 130 cls);
145 t4 = GNUNET_SCHEDULER_add_after (t2, &task4, cls); 131 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &task4, cls);
146 /* t5 will go last (after p4) */
147 GNUNET_SCHEDULER_add_after (t4, &task5, cls);
148} 132}
149 133
150 134
@@ -225,8 +209,8 @@ taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
225 209
226 GNUNET_assert (1 == *ok); 210 GNUNET_assert (1 == *ok);
227 *ok = 0; 211 *ok = 0;
228 GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_after 212 GNUNET_SCHEDULER_cancel (GNUNET_SCHEDULER_add_now
229 (GNUNET_SCHEDULER_NO_TASK, &taskNeverRun, NULL)); 213 (&taskNeverRun, NULL));
230} 214}
231 215
232 216