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/regex/gnunet-regex-profiler.c | |
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/regex/gnunet-regex-profiler.c')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 5a7cb9acd..0e87565c4 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -170,7 +170,7 @@ struct RegexPeer | |||
170 | /** | 170 | /** |
171 | * Operation timeout | 171 | * Operation timeout |
172 | */ | 172 | */ |
173 | GNUNET_SCHEDULER_TaskIdentifier timeout; | 173 | struct GNUNET_SCHEDULER_Task * timeout; |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * Deamon start | 176 | * Deamon start |
@@ -211,17 +211,17 @@ static struct GNUNET_CONFIGURATION_Handle *cfg; | |||
211 | /** | 211 | /** |
212 | * Abort task identifier | 212 | * Abort task identifier |
213 | */ | 213 | */ |
214 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; | 214 | static struct GNUNET_SCHEDULER_Task * abort_task; |
215 | 215 | ||
216 | /** | 216 | /** |
217 | * Shutdown task identifier | 217 | * Shutdown task identifier |
218 | */ | 218 | */ |
219 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | 219 | static struct GNUNET_SCHEDULER_Task * shutdown_task; |
220 | 220 | ||
221 | /** | 221 | /** |
222 | * Host registration task identifier | 222 | * Host registration task identifier |
223 | */ | 223 | */ |
224 | static GNUNET_SCHEDULER_TaskIdentifier register_hosts_task; | 224 | static struct GNUNET_SCHEDULER_Task * register_hosts_task; |
225 | 225 | ||
226 | /** | 226 | /** |
227 | * Global event mask for all testbed events | 227 | * Global event mask for all testbed events |
@@ -296,7 +296,7 @@ static unsigned int next_search; | |||
296 | /** | 296 | /** |
297 | * Search timeout task identifier. | 297 | * Search timeout task identifier. |
298 | */ | 298 | */ |
299 | static GNUNET_SCHEDULER_TaskIdentifier search_timeout_task; | 299 | static struct GNUNET_SCHEDULER_Task * search_timeout_task; |
300 | 300 | ||
301 | /** | 301 | /** |
302 | * Search timeout in seconds. | 302 | * Search timeout in seconds. |
@@ -410,10 +410,10 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
410 | char output_buffer[512]; | 410 | char output_buffer[512]; |
411 | size_t size; | 411 | size_t size; |
412 | 412 | ||
413 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | 413 | shutdown_task = NULL; |
414 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) | 414 | if (NULL != abort_task) |
415 | GNUNET_SCHEDULER_cancel (abort_task); | 415 | GNUNET_SCHEDULER_cancel (abort_task); |
416 | if (GNUNET_SCHEDULER_NO_TASK != register_hosts_task) | 416 | if (NULL != register_hosts_task) |
417 | GNUNET_SCHEDULER_cancel (register_hosts_task); | 417 | GNUNET_SCHEDULER_cancel (register_hosts_task); |
418 | 418 | ||
419 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) | 419 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) |
@@ -479,9 +479,9 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
479 | unsigned long i = (unsigned long) cls; | 479 | unsigned long i = (unsigned long) cls; |
480 | 480 | ||
481 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting from line %lu...\n", i); | 481 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Aborting from line %lu...\n", i); |
482 | abort_task = GNUNET_SCHEDULER_NO_TASK; | 482 | abort_task = NULL; |
483 | result = GNUNET_SYSERR; | 483 | result = GNUNET_SYSERR; |
484 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) | 484 | if (NULL != shutdown_task) |
485 | GNUNET_SCHEDULER_cancel (shutdown_task); | 485 | GNUNET_SCHEDULER_cancel (shutdown_task); |
486 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 486 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
487 | } | 487 | } |
@@ -734,10 +734,10 @@ regex_found_handler (void *cls, | |||
734 | strings_found++; | 734 | strings_found++; |
735 | parallel_searches--; | 735 | parallel_searches--; |
736 | 736 | ||
737 | if (GNUNET_SCHEDULER_NO_TASK != peer->timeout) | 737 | if (NULL != peer->timeout) |
738 | { | 738 | { |
739 | GNUNET_SCHEDULER_cancel (peer->timeout); | 739 | GNUNET_SCHEDULER_cancel (peer->timeout); |
740 | peer->timeout = GNUNET_SCHEDULER_NO_TASK; | 740 | peer->timeout = NULL; |
741 | if (GNUNET_NO == in_shutdown) | 741 | if (GNUNET_NO == in_shutdown) |
742 | GNUNET_SCHEDULER_add_now (&announce_next_regex, NULL); | 742 | GNUNET_SCHEDULER_add_now (&announce_next_regex, NULL); |
743 | } | 743 | } |
@@ -791,10 +791,10 @@ regex_found_handler (void *cls, | |||
791 | "All strings successfully matched in %s\n", | 791 | "All strings successfully matched in %s\n", |
792 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | 792 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); |
793 | 793 | ||
794 | if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task) | 794 | if (NULL != search_timeout_task) |
795 | { | 795 | { |
796 | GNUNET_SCHEDULER_cancel (search_timeout_task); | 796 | GNUNET_SCHEDULER_cancel (search_timeout_task); |
797 | search_timeout_task = GNUNET_SCHEDULER_NO_TASK; | 797 | search_timeout_task = NULL; |
798 | } | 798 | } |
799 | 799 | ||
800 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats.\n"); | 800 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats.\n"); |
@@ -853,7 +853,7 @@ find_timed_out (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
853 | { | 853 | { |
854 | struct RegexPeer *p = cls; | 854 | struct RegexPeer *p = cls; |
855 | 855 | ||
856 | p->timeout = GNUNET_SCHEDULER_NO_TASK; | 856 | p->timeout = NULL; |
857 | 857 | ||
858 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 858 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
859 | return; | 859 | return; |
@@ -996,7 +996,7 @@ announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
996 | if (strings_found != num_peers) | 996 | if (strings_found != num_peers) |
997 | { | 997 | { |
998 | struct GNUNET_TIME_Relative new_delay; | 998 | struct GNUNET_TIME_Relative new_delay; |
999 | if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task) | 999 | if (NULL != search_timeout_task) |
1000 | GNUNET_SCHEDULER_cancel (search_timeout_task); | 1000 | GNUNET_SCHEDULER_cancel (search_timeout_task); |
1001 | new_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15); | 1001 | new_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15); |
1002 | search_timeout_task = GNUNET_SCHEDULER_add_delayed (new_delay, | 1002 | search_timeout_task = GNUNET_SCHEDULER_add_delayed (new_delay, |
@@ -1130,10 +1130,10 @@ test_master (void *cls, | |||
1130 | "Testbed started in %s\n", | 1130 | "Testbed started in %s\n", |
1131 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | 1131 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); |
1132 | 1132 | ||
1133 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) | 1133 | if (NULL != abort_task) |
1134 | { | 1134 | { |
1135 | GNUNET_SCHEDULER_cancel (abort_task); | 1135 | GNUNET_SCHEDULER_cancel (abort_task); |
1136 | abort_task = GNUNET_SCHEDULER_NO_TASK; | 1136 | abort_task = NULL; |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | for (i = 0; i < num_peers; i++) | 1139 | for (i = 0; i < num_peers; i++) |