diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-09 23:14:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-09 23:14:03 +0000 |
commit | 29e6158507a0758192075ac6ece7ba8e75ddc49a (patch) | |
tree | b91ded48da322f8ba4c9bb0f5504228aa036c2d1 /src/util/test_scheduler.c | |
parent | 5dfcb058ab5db9ae0c4b147d8a99c64ca0980028 (diff) | |
download | gnunet-29e6158507a0758192075ac6ece7ba8e75ddc49a.tar.gz gnunet-29e6158507a0758192075ac6ece7ba8e75ddc49a.zip |
small API change: do no longer pass rarely needed GNUNET_SCHEDULER_TaskContext to all scheduler tasks; instead, allow the relatively few tasks that need it to obtain the context via GNUNET_SCHEDULER_get_task_context()
Diffstat (limited to 'src/util/test_scheduler.c')
-rw-r--r-- | src/util/test_scheduler.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/util/test_scheduler.c b/src/util/test_scheduler.c index 01d93febd..a246d75c5 100644 --- a/src/util/test_scheduler.c +++ b/src/util/test_scheduler.c | |||
@@ -31,7 +31,7 @@ static const struct GNUNET_DISK_FileHandle *fds[2]; | |||
31 | 31 | ||
32 | 32 | ||
33 | static void | 33 | static void |
34 | task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 34 | task2 (void *cls) |
35 | { | 35 | { |
36 | int *ok = cls; | 36 | int *ok = cls; |
37 | 37 | ||
@@ -44,7 +44,7 @@ task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
44 | 44 | ||
45 | 45 | ||
46 | static void | 46 | static void |
47 | task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 47 | task3 (void *cls) |
48 | { | 48 | { |
49 | int *ok = cls; | 49 | int *ok = cls; |
50 | 50 | ||
@@ -54,11 +54,13 @@ task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
54 | 54 | ||
55 | 55 | ||
56 | static void | 56 | static void |
57 | taskWrt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 57 | taskWrt (void *cls) |
58 | { | 58 | { |
59 | static char c; | 59 | static char c; |
60 | int *ok = cls; | 60 | int *ok = cls; |
61 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
61 | 62 | ||
63 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
62 | GNUNET_assert (6 == *ok); | 64 | GNUNET_assert (6 == *ok); |
63 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->write_ready, fds[1])); | 65 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->write_ready, fds[1])); |
64 | (*ok) = 7; | 66 | (*ok) = 7; |
@@ -67,14 +69,14 @@ taskWrt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
67 | 69 | ||
68 | 70 | ||
69 | static void | 71 | static void |
70 | taskNeverRun (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 72 | taskNeverRun (void *cls) |
71 | { | 73 | { |
72 | GNUNET_assert (0); | 74 | GNUNET_assert (0); |
73 | } | 75 | } |
74 | 76 | ||
75 | 77 | ||
76 | static void | 78 | static void |
77 | taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 79 | taskLast (void *cls) |
78 | { | 80 | { |
79 | int *ok = cls; | 81 | int *ok = cls; |
80 | 82 | ||
@@ -85,11 +87,13 @@ taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
85 | 87 | ||
86 | 88 | ||
87 | static void | 89 | static void |
88 | taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 90 | taskRd (void *cls) |
89 | { | 91 | { |
90 | static char c; | 92 | static char c; |
91 | int *ok = cls; | 93 | int *ok = cls; |
94 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
92 | 95 | ||
96 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
93 | GNUNET_assert (7 == *ok); | 97 | GNUNET_assert (7 == *ok); |
94 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); | 98 | GNUNET_assert (GNUNET_NETWORK_fdset_handle_isset (tc->read_ready, fds[0])); |
95 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); | 99 | GNUNET_assert (1 == GNUNET_DISK_file_read (fds[0], &c, 1)); |
@@ -101,7 +105,7 @@ taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
101 | 105 | ||
102 | 106 | ||
103 | static void | 107 | static void |
104 | task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 108 | task4 (void *cls) |
105 | { | 109 | { |
106 | int *ok = cls; | 110 | int *ok = cls; |
107 | 111 | ||
@@ -119,7 +123,7 @@ task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
119 | 123 | ||
120 | 124 | ||
121 | static void | 125 | static void |
122 | task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 126 | task1 (void *cls) |
123 | { | 127 | { |
124 | int *ok = cls; | 128 | int *ok = cls; |
125 | 129 | ||
@@ -148,7 +152,7 @@ check () | |||
148 | 152 | ||
149 | 153 | ||
150 | static void | 154 | static void |
151 | taskShutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 155 | taskShutdown (void *cls) |
152 | { | 156 | { |
153 | int *ok = cls; | 157 | int *ok = cls; |
154 | 158 | ||
@@ -176,7 +180,7 @@ checkShutdown () | |||
176 | 180 | ||
177 | #ifndef MINGW | 181 | #ifndef MINGW |
178 | static void | 182 | static void |
179 | taskSig (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 183 | taskSig (void *cls) |
180 | { | 184 | { |
181 | int *ok = cls; | 185 | int *ok = cls; |
182 | 186 | ||
@@ -204,7 +208,7 @@ checkSignal () | |||
204 | 208 | ||
205 | 209 | ||
206 | static void | 210 | static void |
207 | taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 211 | taskCancel (void *cls) |
208 | { | 212 | { |
209 | int *ok = cls; | 213 | int *ok = cls; |
210 | 214 | ||