- bool dispatch_all);
-static void silc_task_queue_alloc(SilcTaskQueue *queue);
-static void silc_task_queue_free(SilcTaskQueue queue);
-static SilcTask silc_task_find(SilcTaskQueue queue, SilcUInt32 fd);
-static SilcTask silc_task_add(SilcTaskQueue queue, SilcTask newtask,
- SilcTaskPriority priority);
-static SilcTask silc_task_get_first(SilcTaskQueue queue, SilcTask first);
-static SilcTask silc_task_add_timeout(SilcTaskQueue queue, SilcTask newtask,
- SilcTaskPriority priority);
-static int silc_schedule_task_remove(SilcTaskQueue queue, SilcTask task);
-static int silc_schedule_task_timeout_compare(struct timeval *smaller,
- struct timeval *bigger);
-static void silc_task_del_by_context(SilcTaskQueue queue, void *context);
-static void silc_task_del_by_callback(SilcTaskQueue queue,
- SilcTaskCallback callback);
-static void silc_task_del_by_fd(SilcTaskQueue queue, SilcUInt32 fd);
-
-/* Returns the task queue by task type */
-#define SILC_SCHEDULE_GET_QUEUE(type) \
- (type == SILC_TASK_FD ? schedule->fd_queue : \
- type == SILC_TASK_TIMEOUT ? schedule->timeout_queue : \
- schedule->generic_queue)
-
-/* Locks. These also blocks signals that we care about and thus guarantee
- that while we are in scheduler no signals can happen. This way we can
- synchronise signals with SILC Scheduler. */
-#define SILC_SCHEDULE_LOCK(schedule) \
-do { \
- silc_schedule_internal_signals_block(schedule->internal); \
- silc_mutex_lock(schedule->lock); \
-} while (0)
-#define SILC_SCHEDULE_UNLOCK(schedule) \
-do { \
- silc_mutex_unlock(schedule->lock); \
- silc_schedule_internal_signals_unblock(schedule->internal); \
-} while (0)
-
-/* SILC Task object. Represents one task in the scheduler. */
-struct SilcTaskStruct {
- SilcUInt32 fd;
- SilcTaskCallback callback; /* Task callback */
- void *context; /* Task callback context */
- struct timeval timeout; /* Set for timeout tasks */
- unsigned int valid : 1; /* Set when task is valid */
- unsigned int priority : 2; /* Priority of the task */
- unsigned int type : 5; /* Type of the task */
-
- /* Pointers forming doubly linked circular list */
- struct SilcTaskStruct *next;
- struct SilcTaskStruct *prev;
-};
-
-/* SILC Task Queue object. The queue holds all the tasks in the scheduler.
- There are always three task queues in the scheduler. One for non-timeout
- tasks (fd tasks performing tasks over specified file descriptor),
- one for timeout tasks and one for generic tasks. */
-struct SilcTaskQueueStruct {
- SilcTask task; /* Pointer to all tasks */
- struct timeval timeout; /* Current timeout */
- SILC_MUTEX_DEFINE(lock); /* Queue's lock */
-};
-
-/*
- SILC Scheduler structure.
-
- This is the actual schedule object in SILC. Both SILC client and server
- uses this same scheduler. Actually, this scheduler could be used by any
- program needing scheduling.
-
- Following short description of the fields:
-
- SilcTaskQueue fd_queue