updates.
[silc.git] / lib / silcutil / silcschedule.h
index 4574cd8c51b12358ddca8e45a84af9e6992b8757..4b23067dd4cf566d7950448aafae8ddde8008304 100644 (file)
@@ -20,7 +20,7 @@
 
 */
  
-/****h* silcutil/silcschedule.h
+/****h* silcutil/SILC Schedule Interface
  *
  * DESCRIPTION
  *
@@ -120,7 +120,7 @@ typedef enum {
   /* File descriptor task that performs some event over file descriptors.
      These tasks are for example network connections. */
   SILC_TASK_FD,
-  
+
   /* Timeout tasks are tasks that are executed after the specified 
      time has elapsed. After the task is executed the task is removed
      automatically from the scheduler. It is safe to re-register the
@@ -172,7 +172,7 @@ typedef enum {
  *
  * NAME
  * 
- *    typedef enum { ... } SilcTaskPriority
+ *    typedef enum { ... } SilcTaskPriority;
  *
  * DESCRIPTION
  *
@@ -199,12 +199,12 @@ typedef enum {
 } SilcTaskPriority;
 /***/
 
-/****f* silcutil/SilcScheduleAPI/silc_schedule_init
+/****f* silcutil/SilcScheduleAPI/SilcTaskCallback
  *
  * SYNOPSIS
  *
  *    typedef void (*SilcTaskCallback)(SilcSchedule schedule, 
- *                                     SilcTaskEvent type, uint32 fd, 
+ *                                     SilcTaskEvent type, SilcUInt32 fd, 
  *                                     void *context);
  *
  * DESCRIPTION
@@ -224,7 +224,7 @@ typedef enum {
  *
  ***/
 typedef void (*SilcTaskCallback)(SilcSchedule schedule, SilcTaskEvent type,
-                                uint32 fd, void *context);
+                                SilcUInt32 fd, void *context);
 
 /* Macros */
 
@@ -259,10 +259,10 @@ typedef void (*SilcTaskCallback)(SilcSchedule schedule, SilcTaskEvent type,
  */
 #define SILC_TASK_CALLBACK(func)                               \
 static void func(SilcSchedule schedule, SilcTaskEvent type,    \
-                uint32 fd, void *context)
+                SilcUInt32 fd, void *context)
 /***/
 
-/****d* silcutil/SilcScheduleAPI/SILC_TASK_CALLBACK
+/****d* silcutil/SilcScheduleAPI/SILC_TASK_CALLBACK_GLOBAL
  *
  * NAME
  * 
@@ -279,7 +279,7 @@ static void func(SilcSchedule schedule, SilcTaskEvent type, \
  */
 #define SILC_TASK_CALLBACK_GLOBAL(func)                        \
 void func(SilcSchedule schedule, SilcTaskEvent type,   \
-         uint32 fd, void *context)
+         SilcUInt32 fd, void *context)
 /***/
 
 /* Prototypes */
@@ -316,6 +316,26 @@ SilcSchedule silc_schedule_init(int max_tasks);
  ***/
 bool silc_schedule_uninit(SilcSchedule schedule);
 
+/****f* silcutil/SilcScheduleAPI/silc_schedule_reinit
+ *
+ * SYNOPSIS
+ *
+ *    SilcSchedule silc_schedule_reinit(int max_tasks);
+ *
+ * DESCRIPTION
+ *
+ *    This function can be called to enlarge the task handling capabilities
+ *    of the scheduler indicated by `schedule'.  The `max_tasks' must be
+ *    larger than what was set in silc_schedule_init function.  This function
+ *    returns FALSE if it cannot reinit the scheduler.  This function does
+ *    not do anything else except ready the scheduler to handle `max_tasks'
+ *    number of tasks after this function returns.  It is safe to call this
+ *    function at any time, and it is guaranteed that existing tasks remain
+ *    as they are in the scheduler.
+ *
+ ***/
+bool silc_schedule_reinit(SilcSchedule schedule, int max_tasks);
+
 /****f* silcutil/SilcScheduleAPI/silc_schedule_stop
  *
  * SYNOPSIS
@@ -326,7 +346,10 @@ bool silc_schedule_uninit(SilcSchedule schedule);
  *
  *    Stops the scheduler even if it is not supposed to be stopped yet. 
  *    After calling this, one must call silc_schedule_uninit (after the 
- *    silc_schedule has returned).
+ *    silc_schedule has returned).  After this is called it is guaranteed
+ *    that next time the scheduler enters the main loop it will be stopped.
+ *    However, untill it enters the main loop it will not detect that
+ *    it is stopped for example if this is called from another thread.
  *
  ***/
 void silc_schedule_stop(SilcSchedule schedule);
@@ -386,7 +409,7 @@ void silc_schedule_wakeup(SilcSchedule schedule);
  *
  * SYNOPSIS
  *
- *    SilcTask silc_schedule_task_add(SilcSchedule schedule, uint32 fd,
+ *    SilcTask silc_schedule_task_add(SilcSchedule schedule, SilcUInt32 fd,
  *                                    SilcTaskCallback callback, 
  *                                    void *context, 
  *                                    long seconds, long useconds, 
@@ -425,7 +448,7 @@ void silc_schedule_wakeup(SilcSchedule schedule);
  *    in other threads as well.
  *   
  ***/
-SilcTask silc_schedule_task_add(SilcSchedule schedule, uint32 fd,
+SilcTask silc_schedule_task_add(SilcSchedule schedule, SilcUInt32 fd,
                                SilcTaskCallback callback, void *context, 
                                long seconds, long useconds, 
                                SilcTaskType type, 
@@ -455,7 +478,7 @@ void silc_schedule_task_del(SilcSchedule schedule, SilcTask task);
  *
  * SYNOPSIS
  *
- *    void silc_schedule_task_del_by_fd(SilcSchedule schedule, uint32 fd);
+ *    void silc_schedule_task_del_by_fd(SilcSchedule schedule, SilcUInt32 fd);
  *
  * DESCRIPTION
  *
@@ -469,7 +492,7 @@ void silc_schedule_task_del(SilcSchedule schedule, SilcTask task);
  *    since generic tasks does not match any specific fd.
  *
  ***/
-void silc_schedule_task_del_by_fd(SilcSchedule schedule, uint32 fd);
+void silc_schedule_task_del_by_fd(SilcSchedule schedule, SilcUInt32 fd);
 
 /****f* silcutil/SilcScheduleAPI/silc_schedule_task_del_by_callback
  *
@@ -513,7 +536,7 @@ void silc_schedule_task_del_by_context(SilcSchedule schedule, void *context);
  *
  * SYNOPSIS
  *
- *    void silc_schedule_set_listen_fd(SilcSchedule schedule, uint32 fd,
+ *    void silc_schedule_set_listen_fd(SilcSchedule schedule, SilcUInt32 fd,
  *                                     SilcTaskEvent mask);
  *
  * DESCRIPTION
@@ -528,14 +551,14 @@ void silc_schedule_task_del_by_context(SilcSchedule schedule, void *context);
  *    times to change the events.
  *
  ***/
-void silc_schedule_set_listen_fd(SilcSchedule schedule, uint32 fd,
+void silc_schedule_set_listen_fd(SilcSchedule schedule, SilcUInt32 fd,
                                 SilcTaskEvent mask);
 
 /****f* silcutil/SilcScheduleAPI/silc_schedule_unset_listen_fd
  *
  * SYNOPSIS
  *
- *    void silc_schedule_unset_listen_fd(SilcSchedule schedule, uint32 fd);
+ *    void silc_schedule_unset_listen_fd(SilcSchedule schedule, SilcUInt32 fd);
  *
  * DESCRIPTION
  *
@@ -544,6 +567,40 @@ void silc_schedule_set_listen_fd(SilcSchedule schedule, uint32 fd,
  *    after calling this function.
  *
  ***/
-void silc_schedule_unset_listen_fd(SilcSchedule schedule, uint32 fd);
+void silc_schedule_unset_listen_fd(SilcSchedule schedule, SilcUInt32 fd);
+
+/****f* silcutil/SilcScheduleAPI/silc_schedule_signal_register
+ *
+ * SYNOPSIS
+ *
+ *    void silc_schedule_signal_register(SilcSchedule schedule, 
+ *                                       SilcUInt32 signal);
+ *
+ * DESCRIPTION
+ *
+ *    Register signal indicated by `signal' to the scheduler.  Application
+ *    should register all signals it is going to use to the scheduler.
+ *    To unregister a signal call silc_schedule_signal_unregister.  On
+ *    platform that does not support signals calling this function has not
+ *    effect.
+ *
+ ***/
+void silc_schedule_signal_register(SilcSchedule schedule, SilcUInt32 signal);
+
+/****f* silcutil/SilcScheduleAPI/silc_schedule_signal_unregister
+ *
+ * SYNOPSIS
+ *
+ *    void silc_schedule_signal_unregister(SilcSchedule schedule, 
+ *                                         SilcUInt32 signal);
+ *
+ * DESCRIPTION
+ *
+ *    Unregister a signal indicated by `signal' from the scheduler.  On
+ *    platform that does not support signals calling this function has no
+ *    effect.
+ *
+ ***/
+void silc_schedule_signal_unregister(SilcSchedule schedule, SilcUInt32 signal);
 
 #endif