return;
silc_schedule_task_add_timeout(f->schedule, silc_fsm_run, f,
seconds, useconds);
+ f->next_later = TRUE;
}
/* Continue after callback or async operation */
void silc_fsm_continue(void *fsm)
{
SilcFSM f = fsm;
- silc_schedule_task_add_timeout(f->schedule, silc_fsm_run, f, 0, 1);
+ if (f->next_later) {
+ silc_schedule_task_del_by_all(f->schedule, 0, silc_fsm_run, f);
+ f->next_later = FALSE;
+ }
+ if (!silc_schedule_task_add_timeout(f->schedule, silc_fsm_run, f, 0, 1))
+ silc_fsm_run(f->schedule, silc_schedule_get_context(f->schedule), 0, 0, f);
}
/* Continue after callback or async operation immediately */
void silc_fsm_continue_sync(void *fsm)
{
SilcFSM f = fsm;
+ if (f->next_later) {
+ silc_schedule_task_del_by_all(f->schedule, 0, silc_fsm_run, f);
+ f->next_later = FALSE;
+ }
silc_fsm_run(f->schedule, silc_schedule_get_context(f->schedule), 0, 0, f);
}
* If both `seconds' and `useconds' are 0, the effect is same as calling
* silc_fsm_next function, and SILC_FSM_CONTINUE must be returned.
*
+ * If silc_fsm_continue or silc_fsm_continue_sync is called while the
+ * machine or thread is in SILC_FSM_WAIT state the timeout is automatically
+ * canceled and the state moves to the next state.
+ *
* EXAMPLE
*
* // Move to next state after 10 seconds
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2005 Pekka Riikonen
+ Copyright (C) 2005 - 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
unsigned int finished : 1; /* Set if SILC_FSM_FINISH returned */
unsigned int sema_timedout : 1; /* Set if waiting sema timedout */
unsigned int synchronous : 1; /* Set if silc_fsm_start_sync called */
+ unsigned int next_later : 1; /* Set if silc_fsm_next_later called */
};
/* Semaphore post context */