diff options
Diffstat (limited to 'src/include/gnunet_scheduler_lib.h')
-rw-r--r-- | src/include/gnunet_scheduler_lib.h | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index d9b63775a..87cb3b6f1 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -65,8 +65,7 @@ enum GNUNET_SCHEDULER_Reason | |||
65 | GNUNET_SCHEDULER_REASON_STARTUP = 1, | 65 | GNUNET_SCHEDULER_REASON_STARTUP = 1, |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * We are shutting down and are running all shutdown-related tasks | 68 | * We are shutting down and are running all shutdown-related tasks. |
69 | * (regardless of timeout, etc.). | ||
70 | */ | 69 | */ |
71 | GNUNET_SCHEDULER_REASON_SHUTDOWN = 2, | 70 | GNUNET_SCHEDULER_REASON_SHUTDOWN = 2, |
72 | 71 | ||
@@ -158,7 +157,7 @@ typedef int | |||
158 | * tasks have completed. On systems with signals, receiving a SIGTERM | 157 | * tasks have completed. On systems with signals, receiving a SIGTERM |
159 | * (and other similar signals) will cause #GNUNET_SCHEDULER_shutdown | 158 | * (and other similar signals) will cause #GNUNET_SCHEDULER_shutdown |
160 | * to be run after the active task is complete. As a result, SIGTERM | 159 | * to be run after the active task is complete. As a result, SIGTERM |
161 | * causes all active tasks to be scheduled with reason | 160 | * causes all shutdown tasks to be scheduled with reason |
162 | * #GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added | 161 | * #GNUNET_SCHEDULER_REASON_SHUTDOWN. (However, tasks added |
163 | * afterwards will execute normally!). Note that any particular | 162 | * afterwards will execute normally!). Note that any particular |
164 | * signal will only shut down one scheduler; applications should | 163 | * signal will only shut down one scheduler; applications should |
@@ -173,11 +172,10 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
173 | 172 | ||
174 | 173 | ||
175 | /** | 174 | /** |
176 | * Request the shutdown of the scheduler. Marks all currently | 175 | * Request the shutdown of a scheduler. Marks all tasks |
177 | * pending tasks as ready because of shutdown. This will | 176 | * awaiting shutdown as ready. Note that tasks |
178 | * cause all tasks to run (as soon as possible, respecting | 177 | * scheduled with #GNUNET_SCHEDULER_add_shutdown() AFTER this call |
179 | * priorities and prerequisite tasks). Note that tasks | 178 | * will be delayed until the next shutdown signal. |
180 | * scheduled AFTER this call may still be delayed arbitrarily. | ||
181 | */ | 179 | */ |
182 | void | 180 | void |
183 | GNUNET_SCHEDULER_shutdown (void); | 181 | GNUNET_SCHEDULER_shutdown (void); |
@@ -272,6 +270,21 @@ GNUNET_SCHEDULER_add_now (GNUNET_SCHEDULER_TaskCallback task, | |||
272 | 270 | ||
273 | 271 | ||
274 | /** | 272 | /** |
273 | * Schedule a new task to be run on shutdown, that is when a CTRL-C | ||
274 | * signal is received, or when #GNUNET_SCHEDULER_shutdown() is being | ||
275 | * invoked. | ||
276 | * | ||
277 | * @param task main function of the task | ||
278 | * @param task_cls closure of @a task | ||
279 | * @return unique task identifier for the job | ||
280 | * only valid until @a task is started! | ||
281 | */ | ||
282 | struct GNUNET_SCHEDULER_Task * | ||
283 | GNUNET_SCHEDULER_add_shutdown (GNUNET_SCHEDULER_TaskCallback task, | ||
284 | void *task_cls); | ||
285 | |||
286 | |||
287 | /** | ||
275 | * Schedule a new task to be run as soon as possible with the | 288 | * Schedule a new task to be run as soon as possible with the |
276 | * (transitive) ignore-shutdown flag either explicitly set or | 289 | * (transitive) ignore-shutdown flag either explicitly set or |
277 | * explicitly enabled. This task (and all tasks created from it, | 290 | * explicitly enabled. This task (and all tasks created from it, |
@@ -296,8 +309,7 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness, | |||
296 | * will be scheduled for execution once the delay has expired. It | 309 | * will be scheduled for execution once the delay has expired. It |
297 | * will be run with the DEFAULT priority. | 310 | * will be run with the DEFAULT priority. |
298 | * | 311 | * |
299 | * * @param delay when should this operation time out? Use | 312 | * @param delay when should this operation time out? |
300 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
301 | * @param task main function of the task | 313 | * @param task main function of the task |
302 | * @param task_cls closure of @a task | 314 | * @param task_cls closure of @a task |
303 | * @return unique task identifier for the job | 315 | * @return unique task identifier for the job |
@@ -313,8 +325,7 @@ GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, | |||
313 | * Schedule a new task to be run with a specified delay. The task | 325 | * Schedule a new task to be run with a specified delay. The task |
314 | * will be scheduled for execution once the delay has expired. | 326 | * will be scheduled for execution once the delay has expired. |
315 | * | 327 | * |
316 | * @param delay when should this operation time out? Use | 328 | * @param delay when should this operation time out? |
317 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
318 | * @param priority priority to use for the task | 329 | * @param priority priority to use for the task |
319 | * @param task main function of the task | 330 | * @param task main function of the task |
320 | * @param task_cls closure of @a task | 331 | * @param task_cls closure of @a task |
@@ -335,8 +346,7 @@ GNUNET_SCHEDULER_add_delayed_with_priority (struct GNUNET_TIME_Relative delay, | |||
335 | * scheduled for execution once either the delay has expired or the | 346 | * scheduled for execution once either the delay has expired or the |
336 | * socket operation is ready. It will be run with the DEFAULT priority. | 347 | * socket operation is ready. It will be run with the DEFAULT priority. |
337 | * | 348 | * |
338 | * * @param delay when should this operation time out? Use | 349 | * * @param delay when should this operation time out? |
339 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
340 | * @param rfd read file-descriptor | 350 | * @param rfd read file-descriptor |
341 | * @param task main function of the task | 351 | * @param task main function of the task |
342 | * @param task_cls closure of @a task | 352 | * @param task_cls closure of @a task |
@@ -358,8 +368,7 @@ GNUNET_SCHEDULER_add_read_net (struct GNUNET_TIME_Relative delay, | |||
358 | * either the delay has expired or the socket operation is ready. It | 368 | * either the delay has expired or the socket operation is ready. It |
359 | * will be run with the DEFAULT priority. | 369 | * will be run with the DEFAULT priority. |
360 | * | 370 | * |
361 | * @param delay when should this operation time out? Use | 371 | * @param delay when should this operation time out? |
362 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
363 | * @param priority priority to use for the task | 372 | * @param priority priority to use for the task |
364 | * @param rfd read file-descriptor | 373 | * @param rfd read file-descriptor |
365 | * @param task main function of the task | 374 | * @param task main function of the task |
@@ -382,8 +391,7 @@ GNUNET_SCHEDULER_add_read_net_with_priority (struct GNUNET_TIME_Relative delay, | |||
382 | * scheduled for execution once either the delay has expired or the | 391 | * scheduled for execution once either the delay has expired or the |
383 | * socket operation is ready. It will be run with the DEFAULT priority. | 392 | * socket operation is ready. It will be run with the DEFAULT priority. |
384 | * | 393 | * |
385 | * * @param delay when should this operation time out? Use | 394 | * * @param delay when should this operation time out? |
386 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
387 | * @param wfd write file-descriptor | 395 | * @param wfd write file-descriptor |
388 | * @param task main function of the task | 396 | * @param task main function of the task |
389 | * @param task_cls closure of @a task | 397 | * @param task_cls closure of @a task |
@@ -404,8 +412,7 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, | |||
404 | * scheduled for execution once either the delay has expired or the | 412 | * scheduled for execution once either the delay has expired or the |
405 | * socket operation is ready. | 413 | * socket operation is ready. |
406 | * | 414 | * |
407 | * @param delay when should this operation time out? Use | 415 | * @param delay when should this operation time out? |
408 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
409 | * @param priority priority of the task | 416 | * @param priority priority of the task |
410 | * @param fd file-descriptor | 417 | * @param fd file-descriptor |
411 | * @param on_read whether to poll the file-descriptor for readability | 418 | * @param on_read whether to poll the file-descriptor for readability |
@@ -431,8 +438,7 @@ GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, | |||
431 | * scheduled for execution once either the delay has expired or the | 438 | * scheduled for execution once either the delay has expired or the |
432 | * socket operation is ready. It will be run with the DEFAULT priority. | 439 | * socket operation is ready. It will be run with the DEFAULT priority. |
433 | * | 440 | * |
434 | * * @param delay when should this operation time out? Use | 441 | * * @param delay when should this operation time out? |
435 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
436 | * @param rfd read file-descriptor | 442 | * @param rfd read file-descriptor |
437 | * @param task main function of the task | 443 | * @param task main function of the task |
438 | * @param task_cls closure of @a task | 444 | * @param task_cls closure of @a task |
@@ -453,8 +459,7 @@ GNUNET_SCHEDULER_add_read_file (struct GNUNET_TIME_Relative delay, | |||
453 | * scheduled for execution once either the delay has expired or the | 459 | * scheduled for execution once either the delay has expired or the |
454 | * socket operation is ready. It will be run with the DEFAULT priority. | 460 | * socket operation is ready. It will be run with the DEFAULT priority. |
455 | * | 461 | * |
456 | * * @param delay when should this operation time out? Use | 462 | * * @param delay when should this operation time out? |
457 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
458 | * @param wfd write file-descriptor | 463 | * @param wfd write file-descriptor |
459 | * @param task main function of the task | 464 | * @param task main function of the task |
460 | * @param task_cls closure of @a task | 465 | * @param task_cls closure of @a task |
@@ -475,8 +480,7 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, | |||
475 | * scheduled for execution once either the delay has expired or the | 480 | * scheduled for execution once either the delay has expired or the |
476 | * socket operation is ready. | 481 | * socket operation is ready. |
477 | * | 482 | * |
478 | * @param delay when should this operation time out? Use | 483 | * @param delay when should this operation time out? |
479 | * #GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
480 | * @param priority priority of the task | 484 | * @param priority priority of the task |
481 | * @param fd file-descriptor | 485 | * @param fd file-descriptor |
482 | * @param on_read whether to poll the file-descriptor for readability | 486 | * @param on_read whether to poll the file-descriptor for readability |
@@ -508,13 +512,11 @@ GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, | |||
508 | * (prerequisite-run) | 512 | * (prerequisite-run) |
509 | * && (delay-ready | 513 | * && (delay-ready |
510 | * || any-rs-ready | 514 | * || any-rs-ready |
511 | * || any-ws-ready | 515 | * || any-ws-ready) |
512 | * || shutdown-active) | ||
513 | * </code> | 516 | * </code> |
514 | * | 517 | * |
515 | * @param prio how important is this task? | 518 | * @param prio how important is this task? |
516 | * @param delay how long should we wait? Use #GNUNET_TIME_UNIT_FOREVER_REL for "forever", | 519 | * @param delay how long should we wait? |
517 | * which means that the task will only be run after we receive SIGTERM | ||
518 | * @param rs set of file descriptors we want to read (can be NULL) | 520 | * @param rs set of file descriptors we want to read (can be NULL) |
519 | * @param ws set of file descriptors we want to write (can be NULL) | 521 | * @param ws set of file descriptors we want to write (can be NULL) |
520 | * @param task main function of the task | 522 | * @param task main function of the task |