Barrelfish
Data Structures | Enumerations | Functions
waitset.h File Reference

Waitset and low-level event handling mechanism. More...

Data Structures

struct  waitset_chanstate
 Per-channel state belonging to waitset. More...
 
struct  waitset
 Wait set. More...
 

Enumerations

Functions

void poll_channels_disabled (dispatcher_handle_t handle)
 Check polled channels.
 
void waitset_init (struct waitset *ws)
 Initialise a new waitset.
 
errval_t waitset_destroy (struct waitset *ws)
 Destroy a previously initialised waitset.
 
errval_t get_next_event (struct waitset *ws, struct event_closure *retclosure)
 Wait for (block) and return next event on given waitset. More...
 
errval_t get_next_event_disabled (struct waitset *ws, struct waitset_chanstate **retchan, struct event_closure *retclosure, struct waitset_chanstate *waitfor, struct waitset_chanstate *waitfor2, dispatcher_handle_t handle, bool debug)
 Get next pending event. More...
 
errval_t event_dispatch (struct waitset *ws)
 Wait for (block) and dispatch next event on given waitset. More...
 
errval_t wait_for_channel (struct waitset *ws, struct waitset_chanstate *channel, errval_t *error_var)
 Dispatch events until a specific event is received. More...
 
errval_t event_dispatch_non_block (struct waitset *ws)
 check and dispatch next event on given waitset More...
 

Detailed Description

Waitset and low-level event handling mechanism.

Enumeration Type Documentation

Current state of a channel on a specific waitset.

Enumerator
CHAN_UNREGISTERED 

Initialised, but not yet registered on a waitset.

CHAN_IDLE 

Has a registered event handler, but the event has not fired.

CHAN_POLLED 

Idle and polled. Channel implementation must be called to check for pending events.

CHAN_PENDING 

Has a pending event waiting to be delivered.

CHAN_WAITING 

There's no registered event handler (for now)

Channel type.

This is used for debugging and to determine the function to call when polling.

Enumerator
CHANTYPE_DEFERRED 

Timer events.

Function Documentation

errval_t event_dispatch ( struct waitset ws)

Wait for (block) and dispatch next event on given waitset.

Wait until something happens, either activity on some channel, or deferred call, and then call the corresponding closure.

Parameters
wsWaitset
errval_t event_dispatch_non_block ( struct waitset ws)

check and dispatch next event on given waitset

Check if there is any pending activity on some channel, or deferred call, and then call the corresponding closure.

Do not wait! In case of no pending events, return err LIB_ERR_NO_EVENT.

Parameters
wsWaitset
errval_t get_next_event ( struct waitset ws,
struct event_closure *  retclosure 
)

Wait for (block) and return next event on given waitset.

Wait until something happens, either activity on some channel, or a deferred call, and then return the corresponding closure. This is the core of the event-handling system.

Parameters
wsWaitset
retclosurePointer to storage space for returned event closure
errval_t get_next_event_disabled ( struct waitset ws,
struct waitset_chanstate **  retchannel,
struct event_closure *  retclosure,
struct waitset_chanstate waitfor,
struct waitset_chanstate waitfor2,
dispatcher_handle_t  handle,
bool  debug 
)

Get next pending event.

Check if there is a pending event that matches current thread and return it. Pending events are in a pending queue and in a waiting queue. A pending event then will be removed from a pending/waiting queue and become unregistered or, if it's persistent, will be re-registered to an idle queue or a polled queue (UMP channels) of a waitset. If there's no pending event, block this thread. If there's a pending event but it doesn't match our thread, don't remove it from a pending queue and wake up a matching thread. If there's no matching thread, add it to a waiting queue.

Parameters
wsWaitset with sources of events
retchannelHolder of returned event
retclosureHolder of returned closure
waitforSpecific event that we're waiting for (can be NULL)
handleDispatcher's handle
debugDebug mode (not used)
errval_t wait_for_channel ( struct waitset ws,
struct waitset_chanstate waitfor,
errval_t *  error_var 
)

Dispatch events until a specific event is received.

Wait for events and dispatch them. If a specific event comes, don't call a closure, just return.

Parameters
wsWaitset
waitforEvent, that we are waiting for
error_varError variable that can be changed by closures