diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-24 11:39:46 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-24 11:39:46 +0000 |
commit | 79d2e869b8c7a4820f63d013024ec34940185461 (patch) | |
tree | 861af7b488f3db9076e80d47e7f129cef517aae7 /src/include/gnunet_scheduler_lib.h | |
parent | 03f90f8752d53540ba4389ea258ec5aecedb879d (diff) | |
download | gnunet-79d2e869b8c7a4820f63d013024ec34940185461.tar.gz gnunet-79d2e869b8c7a4820f63d013024ec34940185461.zip |
Here's another patch for GNUNet's scheduler. It's a smaller version of my last
patch.
This patch extends the scheduler API with two new functions:
GNUNET_SCHEDULER_add_file_with_priority
GNUNET_SCHEDULER_add_net_with_priority
It also re-writes the other net_add/file_add functions to make them call these
more generic functions in order to avoid code duplication.
- Andrew
Diffstat (limited to 'src/include/gnunet_scheduler_lib.h')
-rw-r--r-- | src/include/gnunet_scheduler_lib.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h index 83d9d261a..24e316b47 100644 --- a/src/include/gnunet_scheduler_lib.h +++ b/src/include/gnunet_scheduler_lib.h | |||
@@ -29,6 +29,8 @@ | |||
29 | #ifndef GNUNET_SCHEDULER_LIB_H | 29 | #ifndef GNUNET_SCHEDULER_LIB_H |
30 | #define GNUNET_SCHEDULER_LIB_H | 30 | #define GNUNET_SCHEDULER_LIB_H |
31 | 31 | ||
32 | #include <stdbool.h> | ||
33 | |||
32 | #ifdef __cplusplus | 34 | #ifdef __cplusplus |
33 | extern "C" | 35 | extern "C" |
34 | { | 36 | { |
@@ -468,6 +470,31 @@ GNUNET_SCHEDULER_add_write_net (struct GNUNET_TIME_Relative delay, | |||
468 | 470 | ||
469 | /** | 471 | /** |
470 | * Schedule a new task to be run with a specified delay or when the | 472 | * Schedule a new task to be run with a specified delay or when the |
473 | * specified file descriptor is ready. The delay can be | ||
474 | * used as a timeout on the socket being ready. The task will be | ||
475 | * scheduled for execution once either the delay has expired or the | ||
476 | * socket operation is ready. | ||
477 | * | ||
478 | * @param delay when should this operation time out? Use | ||
479 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
480 | * @param priority priority of the task | ||
481 | * @param fd file-descriptor | ||
482 | * @param on_read whether to poll the file-descriptor for readability | ||
483 | * @param on_write whether to poll the file-descriptor for writability | ||
484 | * @param task main function of the task | ||
485 | * @param task_cls closure of task | ||
486 | * @return unique task identifier for the job | ||
487 | * only valid until "task" is started! | ||
488 | */ | ||
489 | GNUNET_SCHEDULER_TaskIdentifier | ||
490 | GNUNET_SCHEDULER_add_net_with_priority (struct GNUNET_TIME_Relative delay, | ||
491 | enum GNUNET_SCHEDULER_Priority priority, | ||
492 | struct GNUNET_NETWORK_Handle *fd, | ||
493 | bool on_read, bool on_write, | ||
494 | GNUNET_SCHEDULER_Task task, void *task_cls); | ||
495 | |||
496 | /** | ||
497 | * Schedule a new task to be run with a specified delay or when the | ||
471 | * specified file descriptor is ready for reading. The delay can be | 498 | * specified file descriptor is ready for reading. The delay can be |
472 | * used as a timeout on the socket being ready. The task will be | 499 | * used as a timeout on the socket being ready. The task will be |
473 | * scheduled for execution once either the delay has expired or the | 500 | * scheduled for execution once either the delay has expired or the |
@@ -509,6 +536,32 @@ GNUNET_SCHEDULER_add_write_file (struct GNUNET_TIME_Relative delay, | |||
509 | 536 | ||
510 | 537 | ||
511 | /** | 538 | /** |
539 | * Schedule a new task to be run with a specified delay or when the | ||
540 | * specified file descriptor is ready. The delay can be | ||
541 | * used as a timeout on the socket being ready. The task will be | ||
542 | * scheduled for execution once either the delay has expired or the | ||
543 | * socket operation is ready. | ||
544 | * | ||
545 | * @param delay when should this operation time out? Use | ||
546 | * GNUNET_TIME_UNIT_FOREVER_REL for "on shutdown" | ||
547 | * @param priority priority of the task | ||
548 | * @param fd file-descriptor | ||
549 | * @param on_read whether to poll the file-descriptor for readability | ||
550 | * @param on_write whether to poll the file-descriptor for writability | ||
551 | * @param task main function of the task | ||
552 | * @param task_cls closure of task | ||
553 | * @return unique task identifier for the job | ||
554 | * only valid until "task" is started! | ||
555 | */ | ||
556 | GNUNET_SCHEDULER_TaskIdentifier | ||
557 | GNUNET_SCHEDULER_add_file_with_priority (struct GNUNET_TIME_Relative delay, | ||
558 | enum GNUNET_SCHEDULER_Priority priority, | ||
559 | const struct GNUNET_DISK_FileHandle *fd, | ||
560 | bool on_read, bool on_write, | ||
561 | GNUNET_SCHEDULER_Task task, void *task_cls); | ||
562 | |||
563 | |||
564 | /** | ||
512 | * Schedule a new task to be run with a specified delay or when any of | 565 | * Schedule a new task to be run with a specified delay or when any of |
513 | * the specified file descriptor sets is ready. The delay can be used | 566 | * the specified file descriptor sets is ready. The delay can be used |
514 | * as a timeout on the socket(s) being ready. The task will be | 567 | * as a timeout on the socket(s) being ready. The task will be |