diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-24 01:10:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-24 01:10:47 +0000 |
commit | f1f603c7d0b3f03dca46a4f313472288eb080eb1 (patch) | |
tree | 3a29966b02dfb83e0a8a8d5c42b3116380209fb0 /src/conversation | |
parent | 53cd5b8eda2fa8db86b0907a62a39598981d008a (diff) | |
download | gnunet-f1f603c7d0b3f03dca46a4f313472288eb080eb1.tar.gz gnunet-f1f603c7d0b3f03dca46a4f313472288eb080eb1.zip |
making GNUNET_SCHEDULER_cancel() perform in O(1) instead of O(n) to help or even fully address #3247
Diffstat (limited to 'src/conversation')
-rw-r--r-- | src/conversation/gnunet-conversation-test.c | 8 | ||||
-rw-r--r-- | src/conversation/gnunet-conversation.c | 6 | ||||
-rw-r--r-- | src/conversation/test_conversation_api.c | 8 | ||||
-rw-r--r-- | src/conversation/test_conversation_api_twocalls.c | 12 |
4 files changed, 17 insertions, 17 deletions
diff --git a/src/conversation/gnunet-conversation-test.c b/src/conversation/gnunet-conversation-test.c index cc831a3ab..108ca7b5a 100644 --- a/src/conversation/gnunet-conversation-test.c +++ b/src/conversation/gnunet-conversation-test.c | |||
@@ -74,12 +74,12 @@ static struct GNUNET_SPEAKER_Handle *speaker; | |||
74 | /** | 74 | /** |
75 | * Task scheduled to switch from recording to playback. | 75 | * Task scheduled to switch from recording to playback. |
76 | */ | 76 | */ |
77 | static GNUNET_SCHEDULER_TaskIdentifier switch_task; | 77 | static struct GNUNET_SCHEDULER_Task * switch_task; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * The shutdown task. | 80 | * The shutdown task. |
81 | */ | 81 | */ |
82 | static GNUNET_SCHEDULER_TaskIdentifier st; | 82 | static struct GNUNET_SCHEDULER_Task * st; |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Head of DLL with recorded frames. | 85 | * Head of DLL with recorded frames. |
@@ -104,7 +104,7 @@ do_shutdown (void *cls, | |||
104 | { | 104 | { |
105 | struct Recording *rec; | 105 | struct Recording *rec; |
106 | 106 | ||
107 | if (GNUNET_SCHEDULER_NO_TASK != switch_task) | 107 | if (NULL != switch_task) |
108 | GNUNET_SCHEDULER_cancel (switch_task); | 108 | GNUNET_SCHEDULER_cancel (switch_task); |
109 | if (NULL != microphone) | 109 | if (NULL != microphone) |
110 | GNUNET_MICROPHONE_destroy (microphone); | 110 | GNUNET_MICROPHONE_destroy (microphone); |
@@ -134,7 +134,7 @@ switch_to_speaker (void *cls, | |||
134 | { | 134 | { |
135 | struct Recording *rec; | 135 | struct Recording *rec; |
136 | 136 | ||
137 | switch_task = GNUNET_SCHEDULER_NO_TASK; | 137 | switch_task = NULL; |
138 | microphone->disable_microphone (microphone->cls); | 138 | microphone->disable_microphone (microphone->cls); |
139 | if (GNUNET_OK != | 139 | if (GNUNET_OK != |
140 | speaker->enable_speaker (speaker->cls)) | 140 | speaker->enable_speaker (speaker->cls)) |
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c index 4b4c5f5da..7d5cb990a 100644 --- a/src/conversation/gnunet-conversation.c +++ b/src/conversation/gnunet-conversation.c | |||
@@ -173,7 +173,7 @@ static unsigned int line; | |||
173 | /** | 173 | /** |
174 | * Task which handles the commands | 174 | * Task which handles the commands |
175 | */ | 175 | */ |
176 | static GNUNET_SCHEDULER_TaskIdentifier handle_cmd_task; | 176 | static struct GNUNET_SCHEDULER_Task * handle_cmd_task; |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * Our speaker. | 179 | * Our speaker. |
@@ -1036,10 +1036,10 @@ do_stop_task (void *cls, | |||
1036 | GNUNET_CONVERSATION_phone_destroy (phone); | 1036 | GNUNET_CONVERSATION_phone_destroy (phone); |
1037 | phone = NULL; | 1037 | phone = NULL; |
1038 | } | 1038 | } |
1039 | if (GNUNET_SCHEDULER_NO_TASK != handle_cmd_task) | 1039 | if (NULL != handle_cmd_task) |
1040 | { | 1040 | { |
1041 | GNUNET_SCHEDULER_cancel (handle_cmd_task); | 1041 | GNUNET_SCHEDULER_cancel (handle_cmd_task); |
1042 | handle_cmd_task = GNUNET_SCHEDULER_NO_TASK; | 1042 | handle_cmd_task = NULL; |
1043 | } | 1043 | } |
1044 | if (NULL != id) | 1044 | if (NULL != id) |
1045 | { | 1045 | { |
diff --git a/src/conversation/test_conversation_api.c b/src/conversation/test_conversation_api.c index 7a5537144..91ece5c11 100644 --- a/src/conversation/test_conversation_api.c +++ b/src/conversation/test_conversation_api.c | |||
@@ -67,9 +67,9 @@ static GNUNET_MICROPHONE_RecordedDataCallback call_rdc; | |||
67 | 67 | ||
68 | static void *call_rdc_cls; | 68 | static void *call_rdc_cls; |
69 | 69 | ||
70 | static GNUNET_SCHEDULER_TaskIdentifier phone_task; | 70 | static struct GNUNET_SCHEDULER_Task * phone_task; |
71 | 71 | ||
72 | static GNUNET_SCHEDULER_TaskIdentifier call_task; | 72 | static struct GNUNET_SCHEDULER_Task * call_task; |
73 | 73 | ||
74 | 74 | ||
75 | static void | 75 | static void |
@@ -229,14 +229,14 @@ disable_mic (void *cls) | |||
229 | phone_rdc = NULL; | 229 | phone_rdc = NULL; |
230 | phone_rdc_cls = NULL; | 230 | phone_rdc_cls = NULL; |
231 | GNUNET_SCHEDULER_cancel (phone_task); | 231 | GNUNET_SCHEDULER_cancel (phone_task); |
232 | phone_task = GNUNET_SCHEDULER_NO_TASK; | 232 | phone_task = NULL; |
233 | } | 233 | } |
234 | else | 234 | else |
235 | { | 235 | { |
236 | call_rdc = NULL; | 236 | call_rdc = NULL; |
237 | call_rdc_cls = NULL; | 237 | call_rdc_cls = NULL; |
238 | GNUNET_SCHEDULER_cancel (call_task); | 238 | GNUNET_SCHEDULER_cancel (call_task); |
239 | call_task = GNUNET_SCHEDULER_NO_TASK; | 239 | call_task = NULL; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
diff --git a/src/conversation/test_conversation_api_twocalls.c b/src/conversation/test_conversation_api_twocalls.c index 500f0858c..7226ffba1 100644 --- a/src/conversation/test_conversation_api_twocalls.c +++ b/src/conversation/test_conversation_api_twocalls.c | |||
@@ -73,7 +73,7 @@ static GNUNET_MICROPHONE_RecordedDataCallback phone_rdc; | |||
73 | 73 | ||
74 | static void *phone_rdc_cls; | 74 | static void *phone_rdc_cls; |
75 | 75 | ||
76 | static GNUNET_SCHEDULER_TaskIdentifier phone_task; | 76 | static struct GNUNET_SCHEDULER_Task * phone_task; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Variable for recognizing caller1 | 79 | * Variable for recognizing caller1 |
@@ -114,7 +114,7 @@ struct MicContext | |||
114 | 114 | ||
115 | void *rdc_cls; | 115 | void *rdc_cls; |
116 | 116 | ||
117 | GNUNET_SCHEDULER_TaskIdentifier call_task; | 117 | struct GNUNET_SCHEDULER_Task * call_task; |
118 | 118 | ||
119 | }; | 119 | }; |
120 | 120 | ||
@@ -268,14 +268,14 @@ enable_mic (void *cls, | |||
268 | { | 268 | { |
269 | phone_rdc = rdc; | 269 | phone_rdc = rdc; |
270 | phone_rdc_cls = rdc_cls; | 270 | phone_rdc_cls = rdc_cls; |
271 | GNUNET_break (GNUNET_SCHEDULER_NO_TASK == phone_task); | 271 | GNUNET_break (NULL == phone_task); |
272 | phone_task = GNUNET_SCHEDULER_add_now (&phone_send, NULL); | 272 | phone_task = GNUNET_SCHEDULER_add_now (&phone_send, NULL); |
273 | return GNUNET_OK; | 273 | return GNUNET_OK; |
274 | } | 274 | } |
275 | mc = (CALLER1 == cls) ? &call1_mic_ctx : &call2_mic_ctx; | 275 | mc = (CALLER1 == cls) ? &call1_mic_ctx : &call2_mic_ctx; |
276 | mc->rdc = rdc; | 276 | mc->rdc = rdc; |
277 | mc->rdc_cls = rdc_cls; | 277 | mc->rdc_cls = rdc_cls; |
278 | GNUNET_break (GNUNET_SCHEDULER_NO_TASK == mc->call_task); | 278 | GNUNET_break (NULL == mc->call_task); |
279 | mc->call_task = GNUNET_SCHEDULER_add_now (&call_send, mc); | 279 | mc->call_task = GNUNET_SCHEDULER_add_now (&call_send, mc); |
280 | return GNUNET_OK; | 280 | return GNUNET_OK; |
281 | } | 281 | } |
@@ -294,14 +294,14 @@ disable_mic (void *cls) | |||
294 | phone_rdc = NULL; | 294 | phone_rdc = NULL; |
295 | phone_rdc_cls = NULL; | 295 | phone_rdc_cls = NULL; |
296 | GNUNET_SCHEDULER_cancel (phone_task); | 296 | GNUNET_SCHEDULER_cancel (phone_task); |
297 | phone_task = GNUNET_SCHEDULER_NO_TASK; | 297 | phone_task = NULL; |
298 | return; | 298 | return; |
299 | } | 299 | } |
300 | mc = (CALLER1 == cls) ? &call1_mic_ctx : &call2_mic_ctx; | 300 | mc = (CALLER1 == cls) ? &call1_mic_ctx : &call2_mic_ctx; |
301 | mc->rdc = NULL; | 301 | mc->rdc = NULL; |
302 | mc->rdc_cls = NULL; | 302 | mc->rdc_cls = NULL; |
303 | GNUNET_SCHEDULER_cancel (mc->call_task); | 303 | GNUNET_SCHEDULER_cancel (mc->call_task); |
304 | mc->call_task = GNUNET_SCHEDULER_NO_TASK; | 304 | mc->call_task = NULL; |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||