Added SILC_FSM_YIELD.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 11 Sep 2006 15:04:50 +0000 (15:04 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 11 Sep 2006 15:04:50 +0000 (15:04 +0000)
lib/silcutil/silcfsm.c
lib/silcutil/silcfsm.h

index 863516dadd9ac53a40a97ac11ba98d52741a264e..7a0bf4ac100bcb2a3585d0a68679080114fd3c31 100644 (file)
@@ -343,6 +343,11 @@ SILC_TASK_CALLBACK(silc_fsm_run)
   while (status == SILC_FSM_CONTINUE);
 
   switch (status) {
+  case SILC_FSM_YIELD:
+    /* Continue through scheduler */
+    silc_fsm_continue(fsm);
+    break;
+
   case SILC_FSM_WAIT:
     /* The machine is in hold */
     SILC_LOG_DEBUG(("State wait %p", fsm));
index d1e253ecc650f53d580b2783330d41329a438a3c..0eb707c8bd769dc0edf07bdde3a6cb427144bb45 100644 (file)
@@ -29,8 +29,8 @@
  * threads.
  *
  * The FSM provides semaphores because of their versatility.  The FSM
- * semaphores can be used as a conditional variables and signallers, and
- * also as a mutual exclusion locks to protect critical sections.  The FSM
+ * semaphores can be used as mutual exclusion locks to protect critical
+ * sections, and as conditional variables and signallers.  The FSM
  * semaphores can safely be used to synchronize also FSM threads that are
  * executed in real system threads.  This makes SILC FSM very effective
  * tool to implement complex machines whether they are executed in single
@@ -114,12 +114,14 @@ typedef struct SilcFSMObject SilcFSMThreadStruct;
  *
  * DESCRIPTION
  *
- *    Status values that the FSM state functions return.
+ *    Status values that the FSM state functions return.  They dicatate
+ *    how the machine will behave after returning from the state function.
  *
  * SOURCE
  */
 typedef enum {
-  SILC_FSM_CONTINUE,        /* Continue immediately to next state. */
+  SILC_FSM_CONTINUE,        /* Continue immediately to next state */
+  SILC_FSM_YIELD,           /* Continue to next state through scheduler */
   SILC_FSM_WAIT,            /* Wait for some async call or timeout */
   SILC_FSM_FINISH,          /* Finish state machine and call destructor
                                through scheduler */
@@ -588,9 +590,11 @@ void silc_fsm_start_sync(void *fsm, SilcFSMStateCallback start_state);
  *
  *    Set the next state to be executed.  If the state function that
  *    call this function returns SILC_FSM_CONTINUE, the `next_state'
- *    will be executed immediately.  This function must always be used
- *    to set the next state in the machine or thread.  This function is
- *    used with both SilcFSM and SilcFSMThread contexts.
+ *    will be executed immediately.  If it returns SILC_FSM_YIELD it
+ *    yields the thread and the `next_state' will be run after other
+ *    threads have run first.  This function must always be used to set
+ *    the next state in the machine or thread.  This function is used
+ *    with both SilcFSM and SilcFSMThread contexts.
  *
  * EXAMPLE
  *