Pseudo-barriers for simple event handling. More...
Go to the source code of this file.
Typedefs | |
typedef void(* | GNUNET_BarrierStatusCallback) (void *cls, struct GNUNET_BarrierHandle *barrier, int status) |
Functions of this type are to be given as callback argument to GNUNET_init_barrier(). More... | |
typedef void(* | GNUNET_BarrierWaitStatusCallback) (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status) |
Functions of this type are to be given as acallback argument to GNUNET_wait_barrier(). More... | |
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... | |
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.
Definition in file testing_messenger_barrier.h.
typedef void(* GNUNET_BarrierStatusCallback) (void *cls, struct GNUNET_BarrierHandle *barrier, int status) |
Functions of this type are to be given as callback argument to GNUNET_init_barrier().
The callback will be called when status information is available for the pseudo-barrier.
cls | the closure given to GNUNET_init_barrier() |
barrier | the pseudo-barrier handle |
status | status of the pseudo-barrier. The pseudo-barrier is removed once it has been crossed or an error occurs while processing it. Therefore it is invalid to call GNUNET_cancel_barrier() on a crossed or errored pseudo-barrier. |
Definition at line 50 of file testing_messenger_barrier.h.
typedef void(* GNUNET_BarrierWaitStatusCallback) (void *cls, struct GNUNET_BarrierWaitHandle *waiting, int status) |
Functions of this type are to be given as acallback argument to GNUNET_wait_barrier().
The callback will be called when the pseudo-barrier corresponding given in GNUNET_wait_barrier() is crossed or cancelled.
cls | closure pointer given to GNUNET_wait_barrier() |
waiting | the pseudo-barrier wait handle |
status | GNUNET_SYSERR in case of error while waiting for the pseudo-barrier; GNUNET_OK if the pseudo-barrier is crossed |
Definition at line 99 of file testing_messenger_barrier.h.
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().
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().