upipe/upump.h header reference
Upipe event loop handling More
Header inclusion [link]
Members [link]
Types [link]
- typedef void (*upump_cb)(struct upump *)
- enum upump_command
- typedef struct upump_mgr *(*upump_mgr_alloc)(uint16_t , uint16_t )
- enum upump_mgr_command
- enum upump_type
Functions [link]
- 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_restart(struct upump *upump)
- 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 [link]
Description [link]
Upipe event loop handling
Members detail [link]
#define _UPIPE_UPUMP_H_ [link]
This macro is declared in upipe/upump.h source file, line 31.
[link]
This struct is declared in upipe-pthread/upipe_pthread_transfer.h source file, line 46.
| Field | Description |
|---|---|
| struct urefcount * refcount; | pointer to refcount management structure |
| int (*umutex_lock)(struct umutex *) ; | lock mutex |
| int (*umutex_unlock)(struct umutex *) ; | unlock mutex |
[link]
This struct is declared in upipe/upump.h source file, line 109.
| 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 |
| 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) [link]
This function is declared in upipe/upump.h source file, line 246.
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) [link]
This function is declared in upipe/upump.h source file, line 264.
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) [link]
This function is declared in upipe/upump.h source file, line 206.
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) [link]
This function is declared in upipe/upump.h source file, line 282.
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) [link]
This function is declared in upipe/upump.h source file, line 227.
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
struct upump_blocker [link]
This struct is declared in upipe/upump_common.h source file, line 46.
This typedef is declared in upipe/upump.h source file, line 102.
function called when a pump is triggered
enum upump_command [link]
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_RESTART | 7 | restarts the pump (void) |
| UPUMP_CONTROL_LOCAL | 0x8000 | non-standard commands implemented by a upump handler can start from there (first arg = signature) |
This function is declared in upipe/upump.h source file, line 362.
This function frees a upump structure. Please note that the pump must be stopped before.
Parameter list:
- upump: description structure of the pump
#define upump_get_opaque(upump, type) [link]
This macro is declared in upipe/upump.h source file, line 399.
This macro gets the opaque structure with a cast.
Parameter list:
- upump: description structure of the pump
- type: type to cast to return opaque
This function is declared in upipe/upump.h source file, line 376.
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
[link]
This struct is declared in upipe/uprobe_upump_mgr.h source file, line 43.
| 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 |
This typedef is declared in upipe/upump.h source file, line 162.
This typedef allocates a new event loop and a upump manager.
enum upump_mgr_command [link]
This enum is declared in upipe/upump.h source file, line 126.
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) |
#define upump_mgr_get_opaque(upump_mgr, type) [link]
This macro is declared in upipe/upump.h source file, line 442.
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
This function is declared in upipe/upump.h source file, line 432.
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 501.
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
This function is declared in upipe/upump.h source file, line 452.
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 420.
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
This function is declared in upipe/upump.h source file, line 512.
This function instructs an existing upump manager to release all structures currently kept in pools. It is intended 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 352.
This function asks the event loop to restart a timer pump. The timer will be restart to its initial value, as if it was stop, set to its initial value and start. This could be useful to implement IO timeout without freeing and allocating a pump each time data is received.
Parameter list:
- pump: description structure of the pump
This function is declared in upipe/upump.h source file, line 409.
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
This function is declared in upipe/upump.h source file, line 389.
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
This function is declared in upipe/upump.h source file, line 331.
This function asks the event loop to start monitoring a pump.
Parameter list:
- pump: description structure of the pump
This function is declared in upipe/upump.h source file, line 340.
This function asks the event loop to stop monitoring a pump.
Parameter list:
- pump: description structure of the pump
enum upump_type [link]
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, ...) [link]
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 178.
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
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 317.
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
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 298.
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 123.
This function returns a pointer to uchain.
Parameter list:
- sub: pointer to struct uchain
The return value is pointer to struct upump
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 484.
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
This function is for internal use only.
This function is declared in upipe/upump.h source file, line 466.
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 159.
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 159.
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 123.
This function returns a pointer to uchain.
Parameter list:
- upump: pointer to struct upump
The return value is pointer to struct uchain