Added silc_likely and silc_unlikely GCC branch prediction macros.
[silc.git] / lib / silcutil / silcschedule_i.h
index 45441b64cd2e28b5fc7560657bc7673f678e8e0e..3c1598c7fe0901bd429bdaa017a283e8aea8b429 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 - 2005 Pekka Riikonen
+  Copyright (C) 2001 - 2006 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
@@ -45,9 +45,9 @@ typedef struct SilcTaskTimeoutStruct {
 /* Fd task */
 typedef struct {
   struct SilcTaskStruct header;
+  unsigned int events  : 15;
+  unsigned int revents : 15;
   SilcUInt32 fd;
-  unsigned int events  : 16;
-  unsigned int revents : 16;
 } *SilcTaskFd;
 
 /* Scheduler context */
@@ -56,12 +56,12 @@ struct SilcScheduleStruct {
   void *app_context;              /* Application specific context */
   SilcHashTable fd_queue;         /* FD task queue */
   SilcList timeout_queue;         /* Timeout queue */
+  SilcList free_tasks;            /* Timeout task freelist */
   SilcMutex lock;                 /* Scheduler lock */
   struct timeval timeout;         /* Current timeout */
   unsigned int max_tasks     : 28; /* Max FD tasks */
   unsigned int has_timeout   : 1;  /* Set if timeout is set */
   unsigned int valid         : 1;  /* Set if scheduler is valid */
-  unsigned int is_locked     : 1;  /* Set if scheduler is locked */
   unsigned int signal_tasks  : 1;  /* Set if to dispatch signals */
 };
 
@@ -103,11 +103,7 @@ typedef struct {
 
   /* Unregister signal */
   void (*signal_unregister)(SilcSchedule schedule, void *context,
-                           SilcUInt32 signal, SilcTaskCallback callback,
-                           void *callback_context);
-
-  /* Mark signal to be called later. */
-  void (*signal_call)(SilcSchedule schedule, void *context, SilcUInt32 signal);
+                           SilcUInt32 signal);
 
   /* Call all signals */
   void (*signals_call)(SilcSchedule schedule, void *context);
@@ -119,4 +115,19 @@ typedef struct {
   void (*signals_unblock)(SilcSchedule schedule, void *context);
 } SilcScheduleOps;
 
+/* The generic function to add any type of task to the scheduler.  This
+   used to be exported as is to application, but now they should use the
+   macro wrappers defined in silcschedule.h.  For Fd task the timeout must
+   be zero, for timeout task the timeout must not be zero, for signal task
+   the fd argument is the signal. */
+SilcTask silc_schedule_task_add(SilcSchedule schedule, SilcUInt32 fd,
+                               SilcTaskCallback callback, void *context,
+                               long seconds, long useconds,
+                               SilcTaskType type);
+
+#ifdef SILC_DIST_INPLACE
+/* Print scheduler statistics to stdout. */
+void silc_schedule_stats(SilcSchedule schedule);
+#endif /* SILC_DIST_INPLACE */
+
 #endif /* SILCSCHEDULE_I_H */