aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_scheduler.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-04-09 23:14:03 +0000
committerChristian Grothoff <christian@grothoff.org>2016-04-09 23:14:03 +0000
commit29e6158507a0758192075ac6ece7ba8e75ddc49a (patch)
treeb91ded48da322f8ba4c9bb0f5504228aa036c2d1 /src/util/test_scheduler.c
parent5dfcb058ab5db9ae0c4b147d8a99c64ca0980028 (diff)
downloadgnunet-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.c26
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
33static void 33static void
34task2 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 34task2 (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
46static void 46static void
47task3 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 47task3 (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
56static void 56static void
57taskWrt (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 57taskWrt (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
69static void 71static void
70taskNeverRun (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 72taskNeverRun (void *cls)
71{ 73{
72 GNUNET_assert (0); 74 GNUNET_assert (0);
73} 75}
74 76
75 77
76static void 78static void
77taskLast (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 79taskLast (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
87static void 89static void
88taskRd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 90taskRd (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
103static void 107static void
104task4 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 108task4 (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
121static void 125static void
122task1 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 126task1 (void *cls)
123{ 127{
124 int *ok = cls; 128 int *ok = cls;
125 129
@@ -148,7 +152,7 @@ check ()
148 152
149 153
150static void 154static void
151taskShutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 155taskShutdown (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
178static void 182static void
179taskSig (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 183taskSig (void *cls)
180{ 184{
181 int *ok = cls; 185 int *ok = cls;
182 186
@@ -204,7 +208,7 @@ checkSignal ()
204 208
205 209
206static void 210static void
207taskCancel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 211taskCancel (void *cls)
208{ 212{
209 int *ok = cls; 213 int *ok = cls;
210 214