Pseudo-barriers for simple event handling. More...
Go to the source code of this file.
Data Structures | |
struct | GNUNET_BarrierHandle |
struct | GNUNET_BarrierWaitHandle |
Functions | |
struct GNUNET_BarrierHandle * | GNUNET_init_barrier (unsigned int requirement, GNUNET_BarrierStatusCallback cb, void *cb_cls) |
Initialise a pseudo-barrier and call the given callback when the required amount of peers (requirement) reach the pseudo-barrier OR upon error. More... | |
static void | exit_status (struct GNUNET_BarrierHandle *barrier, int status) |
static void | cancel_barrier (void *cls) |
static void | complete_barrier (void *cls) |
void | GNUNET_cancel_barrier (struct GNUNET_BarrierHandle *barrier) |
Cancel a pseudo-barrier. More... | |
struct GNUNET_BarrierWaitHandle * | GNUNET_wait_barrier (struct GNUNET_BarrierHandle *barrier, GNUNET_BarrierWaitStatusCallback cb, void *cb_cls) |
Wait for a pseudo-barrier to be crossed. More... | |
void | GNUNET_cancel_wait_barrier (struct GNUNET_BarrierWaitHandle *waiting) |
Cancel a pseudo-barrier wait handle. More... | |
Pseudo-barriers for simple event handling.
A simple test-case setup for the messenger service.
Definition in file testing_messenger_barrier.c.
struct GNUNET_BarrierHandle* GNUNET_init_barrier | ( | unsigned int | requirement, |
GNUNET_BarrierStatusCallback | cb, | ||
void * | cb_cls | ||
) |
Initialise a pseudo-barrier and call the given callback when the required amount of peers (requirement) reach the pseudo-barrier OR upon error.
requirement | the amount of peers that is required to reach the pseudo-barrier. Peers signal reaching a pseudo-barrier by calling GNUNET_wait_barrier(). |
cb | the callback to call when the pseudo-barrier is reached or upon error. Can be NULL. |
cb_cls | closure for the above callback |
Definition at line 42 of file testing_messenger_barrier.c.
References GNUNET_BarrierHandle::cb, GNUNET_BarrierHandle::cls, GNUNET_new, GNUNET_BarrierHandle::head, GNUNET_BarrierHandle::requirement, GNUNET_BarrierHandle::tail, and GNUNET_BarrierHandle::task.
Referenced by barrier_cb(), and GNUNET_run_messenger_setup().
|
static |
Definition at line 101 of file testing_messenger_barrier.c.
References GNUNET_BarrierWaitHandle::barrier, GNUNET_BarrierHandle::cb, GNUNET_BarrierWaitHandle::cb, GNUNET_BarrierHandle::cls, GNUNET_BarrierWaitHandle::cls, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_BarrierHandle::head, GNUNET_BarrierWaitHandle::next, status, and GNUNET_BarrierHandle::tail.
Referenced by cancel_barrier(), and complete_barrier().
|
static |
Definition at line 69 of file testing_messenger_barrier.c.
References GNUNET_BarrierHandle::cls, exit_status(), and GNUNET_SYSERR.
Referenced by GNUNET_cancel_barrier().
|
static |
Definition at line 75 of file testing_messenger_barrier.c.
References GNUNET_BarrierHandle::cls, exit_status(), and GNUNET_OK.
Referenced by GNUNET_wait_barrier().
void GNUNET_cancel_barrier | ( | struct GNUNET_BarrierHandle * | barrier | ) |
Cancel a pseudo-barrier.
barrier | the pseudo-barrier handle |
Definition at line 81 of file testing_messenger_barrier.c.
References cancel_barrier(), GNUNET_SCHEDULER_add_now(), and GNUNET_BarrierHandle::task.
Referenced by shutdown_cb().
struct GNUNET_BarrierWaitHandle* GNUNET_wait_barrier | ( | struct GNUNET_BarrierHandle * | barrier, |
GNUNET_BarrierWaitStatusCallback | cb, | ||
void * | cb_cls | ||
) |
Wait for a pseudo-barrier to be crossed.
This function should be called for the peers which have been started by the testbed.
barrier | the pseudo-barrier handle |
cb | the pseudo-barrier wait callback |
cb_cls | the closure for the above callback |
Definition at line 125 of file testing_messenger_barrier.c.
References GNUNET_BarrierWaitHandle::barrier, GNUNET_BarrierWaitHandle::cb, GNUNET_BarrierWaitHandle::cls, complete_barrier(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_BarrierHandle::head, GNUNET_BarrierWaitHandle::next, GNUNET_BarrierWaitHandle::prev, GNUNET_BarrierHandle::requirement, GNUNET_BarrierHandle::tail, and GNUNET_BarrierHandle::task.
Referenced by on_message(), and on_peer().
void GNUNET_cancel_wait_barrier | ( | struct GNUNET_BarrierWaitHandle * | waiting | ) |
Cancel a pseudo-barrier wait handle.
Should not be called in or after the callback given to GNUNET_wait_barrier() has been called.
waiting | the pseudo-barrier wait handle |
Definition at line 153 of file testing_messenger_barrier.c.
References GNUNET_BarrierWaitHandle::barrier, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_BarrierHandle::head, GNUNET_BarrierHandle::requirement, GNUNET_BarrierHandle::tail, and GNUNET_BarrierHandle::task.
Referenced by on_message(), and shutdown_cb().