flux_reactor_create(3)
SYNOPSIS
#include <flux/core.h>
flux_reactor_t *flux_reactor_create (int flags);
void flux_reactor_destroy (flux_reactor_t *r);
int flux_reactor_run (flux_reactor_t *r, int flags);
void flux_reactor_stop (flux_reactor_t *r);
void flux_reactor_stop_error (flux_reactor_t *r);
Link with -lflux-core.
DESCRIPTION
flux_reactor_create() creates a flux_reactor_t object which can
be used to monitor for events on file descriptors, timers, and
flux_t broker handles. flags should be set to zero.
For each event source and type that is to be monitored, a flux_watcher_t
object is created using a type-specific create function, and started
with flux_watcher_start(3).
For each event source and type that is to be monitored, a
flux_watcher_t object is created and associated with a specific
reactor using a type-specific create function, and started with
flux_watcher_start(3). To receive events, control must be transferred
to the reactor event loop by calling flux_reactor_run().
The full list of flux reactor run flags is as follows:
- FLUX_REACTOR_NOWAIT
Run one reactor loop iteration without blocking.
- FLUX_REACTOR_ONCE
Run one reactor loop iteration, blocking until at least one event is handled.
flux_reactor_run() processes events until one of the following conditions
is met:
There are no more active watchers.
The
flux_reactor_stop()orflux_reactor_stop_error()functions are called by one of the watchers.Flags include FLUX_REACTOR_NOWAIT and one reactor loop iteration has been completed.
Flags include FLUX_REACTOR_ONCE, at least one event has been handled, and one reactor loop iteration has been completed.
If flux_reactor_stop_error() is called, this will cause
flux_reactor_run() to return -1 indicating that an error has occurred.
The caller should ensure that a valid error code has been assigned to
errno(3) before calling this function.
flux_reactor_destroy() releases an internal reference taken at
flux_reactor_create() time. Freeing of the underlying resources will
be deferred if there are any remaining watchers associated with the reactor.
RETURN VALUE
flux_reactor_create() returns a flux_reactor_t object on success.
On error, NULL is returned, and errno is set appropriately.
flux_reactor_run() returns the number of active watchers on success.
On failure, it returns -1 with errno set. A failure return is triggered
when the application sets errno and calls
flux_reactor_stop_error().
ERRORS
- ENOMEM
Out of memory.
RESOURCES
Flux: http://flux-framework.org
Flux RFC: https://flux-framework.readthedocs.io/projects/flux-rfc
Issue Tracker: https://github.com/flux-framework/flux-core/issues
SEE ALSO
flux_fd_watcher_create(3), flux_handle_watcher_create(3), flux_timer_watcher_create(3), flux_watcher_start(3)