upipe/upump.h header reference
Upipe event loop handling More
Header inclusion
Members
Types
- struct upump
- typedef void (*upump_cb)(struct upump *)
- enum upump_command
- struct upump_mgr
- typedef struct upump_mgr *(*upump_mgr_alloc)(uint16_t , uint16_t )
- enum upump_mgr_command
- enum upump_type
Functions
- struct upump * upump_alloc_fd_read(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount, int fd)
- struct upump * upump_alloc_fd_write(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount, int fd)
- struct upump * upump_alloc_idler(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount)
- struct upump * upump_alloc_signal(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount, int signal)
- struct upump * upump_alloc_timer(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount, uint64_t after, uint64_t repeat)
- void upump_free(struct upump *upump)
- void upump_get_status(struct upump *upump, bool *status_p)
- void upump_mgr_release(struct upump_mgr *mgr)
- int upump_mgr_run(struct upump_mgr *mgr, struct umutex *mutex)
- void upump_mgr_set_opaque(struct upump_mgr *upump_mgr, void *opaque)
- struct upump_mgr * upump_mgr_use(struct upump_mgr *mgr)
- int upump_mgr_vacuum(struct upump_mgr *mgr)
- void upump_set_cb(struct upump *upump, upump_cb cb, void *opaque)
- void upump_set_status(struct upump *upump, bool status)
- void upump_start(struct upump *upump)
- void upump_stop(struct upump *upump)
Macros
Description
Upipe event loop handling
Members detail
This macro is declared in upipe/upump.h source file, line 31.
This struct is declared in upipe/upump.h source file, line 107.
This struct stores a pump of a given event loop.
The structure is not refcounted and shouldn't be used by more than one thread at once.
Field | Description |
---|---|
struct uchain uchain; | structure for double-linked lists - for use by the allocating pipe |
struct upump_mgr * mgr; | pointer to the event loop manager |
bool started; | true if upump_start() was called on the pump |
struct uchain blockers; | blockers registered on this pump |
upump_cb cb; | function to call back when triggered |
void * opaque; | opaque pointer for the callback |
struct urefcount * refcount; | pointer to urefcount structure to increment during callback |
struct upump * upump_alloc_fd_read(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount, int fd)
This function is declared in upipe/upump.h source file, line 249.
This function allocates and initializes a pump for a readable file descriptor.
Parameter list:
- mgr: management structure for this event loop
- cb: function to call when the pump triggers
- opaque: pointer to the module's internal structure
- refcount: pointer to urefcount structure to increment during callback, or NULL
- fd: file descriptor to watch
The return value is pointer to allocated pump, or NULL in case of failure
struct upump * upump_alloc_fd_write(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount, int fd)
This function is declared in upipe/upump.h source file, line 267.
This function allocates and initializes a pump for a writable file descriptor.
Parameter list:
- mgr: management structure for this event loop
- cb: function to call when the pump triggers
- opaque: pointer to the module's internal structure
- refcount: pointer to urefcount structure to increment during callback, or NULL
- fd: file descriptor to watch
The return value is pointer to allocated pump, or NULL in case of failure
struct upump * upump_alloc_idler(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount)
This function is declared in upipe/upump.h source file, line 209.
This function allocates and initializes an idler pump.
Parameter list:
- mgr: management structure for this event loop
- cb: function to call when the pump triggers
- opaque: pointer to the module's internal structure
- refcount: pointer to urefcount structure to increment during callback, or NULL
The return value is pointer to allocated pump, or NULL in case of failure
struct upump * upump_alloc_signal(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount, int signal)
This function is declared in upipe/upump.h source file, line 285.
This function allocates and initializes a pump for a signal.
Parameter list:
- mgr: management structure for this event loop
- cb: function to call when the pump triggers
- opaque: pointer to the module's internal structure
- refcount: pointer to urefcount structure to increment during callback, or NULL
- signal: signal to watch
The return value is pointer to allocated pump, or NULL in case of failure
struct upump * upump_alloc_timer(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount, uint64_t after, uint64_t repeat)
This function is declared in upipe/upump.h source file, line 230.
This function allocates and initializes a pump for a timer.
Parameter list:
- mgr: management structure for this event loop
- cb: function to call when the pump triggers
- opaque: pointer to the module's internal structure
- refcount: pointer to urefcount structure to increment during callback, or NULL
- after: time after which it triggers, in ticks of a 27 MHz monotonic clock
- repeat: pump will trigger again each repeat occurrence, in ticks of a 27 MHz monotonic clock (0 to disable)
The return value is pointer to allocated pump, or NULL in case of failure
typedef void (*upump_cb)(struct upump *)
This typedef is declared in upipe/upump.h source file, line 100.
function called when a pump is triggered
This enum is declared in upipe/upump.h source file, line 78.
This enum defines standard commands which upump handlers may implement.
Identifier | Value | Description |
---|---|---|
UPUMP_START | 0 | starts the pump (void) |
UPUMP_STOP | 1 | stops the pump (void) |
UPUMP_FREE | 2 | frees the pump (void) |
UPUMP_GET_STATUS | 3 | gets the pump blocking status (int *) |
UPUMP_SET_STATUS | 4 | sets the pump blocking status (int) |
UPUMP_ALLOC_BLOCKER | 5 | allocates a blocker (struct upump_blocker **) |
UPUMP_FREE_BLOCKER | 6 | frees a blocker (struct upump_blocker *) |
UPUMP_CONTROL_LOCAL | 0x8000 | non-standard commands implemented by a upump handler can start from there (first arg = signature) |
void upump_free(struct upump *upump)
This function is declared in upipe/upump.h source file, line 353.
This function frees a upump structure. Please note that the pump must be stopped before.
Parameter list:
- upump: description structure of the pump
This macro is declared in upipe/upump.h source file, line 390.
This macro gets the opaque structure with a cast.
Parameter list:
- upump: description structure of the pump
- type: type to cast to return opaque
void upump_get_status(struct upump *upump, bool *status_p)
This function is declared in upipe/upump.h source file, line 367.
This function gets the blocking status of a pump (whether the event loop will quit if the pump is the only active pump).
Parameter list:
- upump: description structure of the pump
- status_p: reference to boolean representing the blocking status of a pump
This struct is declared in upipe/upump.h source file, line 141.
This struct stores common management parameters for a given event loop.
Field | Description |
---|---|
struct urefcount * refcount; | pointer to refcount management structure |
unsigned int signature; | signature of the upump handler |
struct uchain uchain; | structure for double-linked lists - for use by the application only |
void * opaque; | opaque - for use by the application only |
struct upump *(*upump_alloc)(struct upump_mgr *, int va_list ) ; | function to create a pump |
int (*upump_control)(struct upump *, int va_list ) ; | control function for standard or local commands - all parameters belong to the caller |
int (*upump_mgr_control)(struct upump_mgr *, int va_list ) ; | control function for standard or local manager commands - all parameters belong to the caller |
typedef struct upump_mgr *(*upump_mgr_alloc)(uint16_t , uint16_t )
This typedef is declared in upipe/upump.h source file, line 165.
This typedef allocates a new event loop and a upump manager.
This enum is declared in upipe/upump.h source file, line 129.
This enum defines standard commands which upump managers may implement.
Identifier | Value | Description |
---|---|---|
UPUMP_MGR_RUN | 0 | run the event loop (struct umutex *) |
UPUMP_MGR_VACUUM | 1 | release all buffers kept in pools (void) |
UPUMP_MGR_CONTROL_LOCAL | 0x8000 | non-standard manager commands implemented by a upump handler can start from there (first arg = signature) |
This macro is declared in upipe/upump.h source file, line 433.
This macro gets the opaque member of a upump manager.
Parameter list:
- upump_mgr: pointer to upump_mgr
- type: type to cast to
The return value is opaque
void upump_mgr_release(struct upump_mgr *mgr)
This function is declared in upipe/upump.h source file, line 423.
This function decrements the reference count of a upump manager of frees it.
Parameter list:
- mgr: pointer to upump manager
This function is declared in upipe/upump.h source file, line 492.
This function runs an event loop until no pump is active.
Parameter list:
- mgr: pointer to upump manager
- mutex: mutual exclusion primitives to access the event loop
The return value is an error code, including UBASE_ERR_BUSY, if a pump is still active
void upump_mgr_set_opaque(struct upump_mgr *upump_mgr, void *opaque)
This function is declared in upipe/upump.h source file, line 443.
This function sets the opaque member of a upump manager
Parameter list:
- upump_mgr: pointer to upump_mgr
- opaque: opaque
This function is declared in upipe/upump.h source file, line 411.
This function increments the reference count of a upump manager.
Parameter list:
- mgr: pointer to upump manager
The return value is same pointer to upump manager
int upump_mgr_vacuum(struct upump_mgr *mgr)
This function is declared in upipe/upump.h source file, line 503.
This function instructs an existing upump manager to release all structures currently kept in pools. It is inteded as a debug tool only.
Parameter list:
- mgr: pointer to upump manager
The return value is an error code
This function is declared in upipe/upump.h source file, line 400.
This function sets the callback parameters of an existing pump.
Parameter list:
- upump: description structure of the pump
- cb: function to call when the pump triggers
- opaque: pointer to the module's internal structure
void upump_set_status(struct upump *upump, bool status)
This function is declared in upipe/upump.h source file, line 380.
This function sets the blocking status of a pump (whether the event loop will quit if the pump is the only active pump).
Parameter list:
- upump: description structure of the pump
- status: boolean setting the blocking status of a pump
void upump_start(struct upump *upump)
This function is declared in upipe/upump.h source file, line 334.
This function asks the event loop to start monitoring a pump.
Parameter list:
- pump: description structure of the pump
void upump_stop(struct upump *upump)
This function is declared in upipe/upump.h source file, line 343.
This function asks the event loop to stop monitoring a pump.
Parameter list:
- pump: description structure of the pump
This enum is declared in upipe/upump.h source file, line 56.
This enum defines the standard types of pumps.
Identifier | Value | Description |
---|---|---|
UPUMP_TYPE_IDLER | 0 | event continuously triggers (no argument) |
UPUMP_TYPE_TIMER | 1 | event triggers once after a given timeout (arguments = uint64_t, uint64_t) |
UPUMP_TYPE_FD_READ | 2 | event triggers on available data from file descriptor (argument = int) |
UPUMP_TYPE_FD_WRITE | 3 | event triggers on available writing space to file descriptor (argument = int) |
UPUMP_TYPE_SIGNAL | 4 | event triggers on a UNIX signal (argument = int) |
UPUMP_TYPE_LOCAL | 0x8000 | non-standard types implemented by a upump handler can start from there (first arg = signature) |
struct upump * upump_alloc(struct upump_mgr *mgr, upump_cb cb, void *opaque, struct urefcount *refcount, int event, ...)
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 181.
This function allocates and initializes a pump.
Parameter list:
- mgr: management structure for this event loop
- cb: function to call when the pump triggers
- opaque: pointer to the module's internal structure
- refcount: pointer to urefcount structure to increment during callback, or NULL
- event: type of event to watch for, followed by optional parameters
The return value is pointer to allocated pump, or NULL in case of failure
int upump_control(struct upump *upump, int command, ...)
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 320.
This function sends a control command to the pump. Note that all control commands must be executed from the same thread - no reentrancy or locking is required from the pump. Also note that all arguments are owned by the caller.
Parameter list:
- upump: description structure of the pump
- command: control command to send, followed by optional read or write parameters
The return value is an error code
int upump_control_va(struct upump *upump, int command, va_list args)
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 301.
This function sends a control command to the pump. Note that all control commands must be executed from the same thread - no reentrancy or locking is required from the pump. Also note that all arguments are owned by the caller.
Parameter list:
- upump: description structure of the pump
- command: control command to send
- args: optional read or write parameters
The return value is an error code
This function is for internal use only.
This function is declared in UBASE_FROM_TO function like macro expansion, line 19 in upipe/upump.h source file, line 126.
This function returns a pointer to uchain.
Parameter list:
- sub: pointer to struct uchain
The return value is pointer to struct upump
int upump_mgr_control(struct upump_mgr *mgr, int command, ...)
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 475.
This function sends a control command to the pipe manager. Note that thread semantics depend on the pipe manager. Also note that all arguments are owned by the caller.
Parameter list:
- mgr: pointer to upump manager
- command: control manager command to send, followed by optional read or write parameters
The return value is an error code
int upump_mgr_control_va(struct upump_mgr *mgr, int command, va_list args)
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 457.
This function sends a control command to the upump manager. Note that all arguments are owned by the caller.
Parameter list:
- mgr: pointer to upump manager
- command: manager control command to send
- args: optional read or write parameters
The return value is an error code
This function is for internal use only.
This function is declared in UBASE_FROM_TO function like macro expansion, line 19 in upipe/upump.h source file, line 162.
This function returns a pointer to uchain.
Parameter list:
- sub: pointer to struct uchain
The return value is pointer to struct upump_mgr
This function is for internal use only.
This function is declared in UBASE_FROM_TO function like macro expansion, line 9 in upipe/upump.h source file, line 162.
This function returns a pointer to uchain.
Parameter list:
- upump_mgr: pointer to struct upump_mgr
The return value is pointer to struct uchain
This function is for internal use only.
This function is declared in UBASE_FROM_TO function like macro expansion, line 9 in upipe/upump.h source file, line 126.
This function returns a pointer to uchain.
Parameter list:
- upump: pointer to struct upump
The return value is pointer to struct uchain