build_event

March 26, 2020 Contributors

Name

build_event — Create an event

Synopsis

#include "event.h"

| Event * **build_event** ( | when, |   |
|   | whence, |   |
|   | fd, |   |
|   | callback, |   |
|   | closure); |   |

struct timeval <var class="pdparam">when</var>;
int <var class="pdparam">whence</var>;
int <var class="pdparam">fd</var>;
EventFunc <var class="pdparam">callback</var>;
void *<var class="pdparam">closure</var>;

Description

Create an event. The Event structure encapsulates a file descriptor and an action that should be triggered when IO is signalled on that descriptor. The event system keys events by file descriptor; you can only have one instance of an Event structure scheduled for a given descriptor. You may have multiple event structures that reference the same descriptor, but only one of those can be active in the Scheduler at a given time.

Defines of this Function

The build_event_from_epoch and the build_event_from_now functions are defined in the following way:

#define build_event_from_epoch(a,b,c,d) build_event((a), \
                                        E_FROM_EPOCH, (b), (c), (d))
#define build_event_from_now(a,b,c,d) build_event((a), \
                                        E_FROM_NOW, (b), (c), (d))

Parameters

when

When the event should begin.

whence

Use the contants E_FROM_EPOCH or E_FROM_NOW for this parameter.

fd

The file descriptor.

callback

The callback function.

closure

The closure function.

Return Values

This function returns an Event.

Threading

Warning

Only call this function from the Scheduler thread.

See Also

“Event” and “The Event API”