Integer type name change.
[silc.git] / lib / silcutil / silcschedule.h
index b2597f74772971f128831212455e3c12a05882ed..b0e315fda678cb64bd727b3c2348587ecd4e52bd 100644 (file)
@@ -1,26 +1,28 @@
-/****h* silcutil/silcschedule.h
- *
- * NAME
- *
- * silcschedule.h
- *
- * COPYRIGHT
- *
- * Author: Pekka Riikonen <priikone@silcnet.org>
- *
- * Copyright (C) 1998 - 2001 Pekka Riikonen
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+/*
+  
+  silcschedule.h
+  COPYRIGHT
+  Author: Pekka Riikonen <priikone@silcnet.org>
+  Copyright (C) 1998 - 2001 Pekka Riikonen
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+*/
+/****h* silcutil/SilcScheduleAPI
  *
# DESCRIPTION
* DESCRIPTION
  *
  * The SILC Scheduler is the heart of any application. The scheduler provides
  * the application's main loop that can handle incoming data, outgoing data,
@@ -63,7 +65,7 @@
  * application could be created by allocating own scheduler for each of the
  * worker threads.
  *
- */
+ ***/
 
 #ifndef SILCSCHEDULE_H
 #define SILCSCHEDULE_H
@@ -170,7 +172,7 @@ typedef enum {
  *
  * NAME
  * 
- *    typedef enum { ... } SilcTaskPriority
+ *    typedef enum { ... } SilcTaskPriority;
  *
  * DESCRIPTION
  *
@@ -197,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
@@ -222,7 +224,7 @@ typedef enum {
  *
  ***/
 typedef void (*SilcTaskCallback)(SilcSchedule schedule, SilcTaskEvent type,
-                                uint32 fd, void *context);
+                                SilcUInt32 fd, void *context);
 
 /* Macros */
 
@@ -257,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
  * 
@@ -277,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 */
@@ -314,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
@@ -324,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);
@@ -344,7 +369,7 @@ void silc_schedule_stop(SilcSchedule schedule);
  ***/
 void silc_schedule(SilcSchedule schedule);
 
-/****f* silcutil/SilcScheduleAPI/silc_schedule
+/****f* silcutil/SilcScheduleAPI/silc_schedule_one
  *
  * SYNOPSIS
  *
@@ -384,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, 
@@ -423,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, 
@@ -453,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
  *
@@ -463,8 +488,11 @@ void silc_schedule_task_del(SilcSchedule schedule, SilcTask task);
  *    in task callbacks (including in the task's own task callback) and
  *    in multi-threaded environment in other threads as well.
  *
+ *    Note that generic tasks cannot be deleted using this function
+ *    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
  *
@@ -508,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
@@ -523,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
  *
@@ -539,6 +567,6 @@ 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);
 
 #endif