libonion
|
#include "types.h"
Typedefs | |
typedef enum onion_poller_slot_type_e | onion_poller_slot_type_e |
Enumerations | |
enum | onion_poller_slot_type_e { O_POLL_READ = 1, O_POLL_WRITE = 2, O_POLL_OTHER = 4, O_POLL_ALL = 7 } |
Functions | |
onion_poller_slot * | onion_poller_slot_new (int fd, int(*f)(void *), void *data) |
Create a new slot for the poller. | |
void | onion_poller_slot_free (onion_poller_slot *el) |
Cleans a poller slot. Do not call if already on the poller (onion_poller_add). Use onion_poller_remove instead. | |
void | onion_poller_slot_set_shutdown (onion_poller_slot *el, void(*shutdown)(void *), void *data) |
Sets the shutdown function for this poller slot. | |
void | onion_poller_slot_set_timeout (onion_poller_slot *el, int timeout_ms) |
Sets the timeout for this slot. Current implementation takes ms, but then it rounds to seconds. | |
void | onion_poller_slot_set_type (onion_poller_slot *el, onion_poller_slot_type_e type) |
Sets the polling type: read/write/other. O_POLL_READ | O_POLL_WRITE | O_POLL_OTHER. | |
onion_poller * | onion_poller_new (int aprox_n) |
Create a new poller. | |
void | onion_poller_free (onion_poller *) |
Frees the poller. It first stops it. | |
void | onion_poller_set_queue_size_per_thread (onion_poller *poller, size_t count) |
Sets the max events per thread queue size. | |
int | onion_poller_add (onion_poller *poller, onion_poller_slot *el) |
Adds a slot to the poller. | |
onion_poller_slot * | onion_poller_get (onion_poller *poller, int fd) |
Gets the poller to do some modifications as change shutdown. | |
int | onion_poller_remove (onion_poller *poller, int fd) |
Removes a fd from the poller. | |
void | onion_poller_poll (onion_poller *) |
Do the polling. If on several threads, this is done in every thread. | |
void | onion_poller_stop (onion_poller *) |
Stops the polling. This only marks the flag, and should be cancelled with pthread_cancel. |
typedef enum onion_poller_slot_type_e onion_poller_slot_type_e |
int onion_poller_add | ( | onion_poller * | poller, |
onion_poller_slot * | el | ||
) |
Adds a slot to the poller.
References onion_poller_t::base, and onion_poller_t::loop.
void onion_poller_free | ( | onion_poller * | ) |
Frees the poller. It first stops it.
References onion_poller_t::base, and onion_low_free().
onion_poller* onion_poller_new | ( | int | aprox_n | ) |
Create a new poller.
References onion_poller_t::base, onion_poller_t::loop, onion_low_calloc(), and onion_poller_t::sem.
void onion_poller_poll | ( | onion_poller * | ) |
Do the polling. If on several threads, this is done in every thread.
References onion_poller_t::base, onion_poller_t::loop, onion_poller_t::sem, and onion_poller_t::stop.
int onion_poller_remove | ( | onion_poller * | poller, |
int | fd | ||
) |
Removes a fd from the poller.
References ONION_ERROR.
void onion_poller_slot_free | ( | onion_poller_slot * | el | ) |
Cleans a poller slot. Do not call if already on the poller (onion_poller_add). Use onion_poller_remove instead.
onion_poller_slot* onion_poller_slot_new | ( | int | fd, |
int(*)(void *) | f, | ||
void * | data | ||
) |
Create a new slot for the poller.
References onion_low_calloc().
void onion_poller_slot_set_shutdown | ( | onion_poller_slot * | el, |
void(*)(void *) | shutdown, | ||
void * | data | ||
) |
Sets the shutdown function for this poller slot.
void onion_poller_slot_set_timeout | ( | onion_poller_slot * | el, |
int | timeout_ms | ||
) |
Sets the timeout for this slot. Current implementation takes ms, but then it rounds to seconds.
void onion_poller_stop | ( | onion_poller * | ) |
Stops the polling. This only marks the flag, and should be cancelled with pthread_cancel.
References onion_poller_t::base, onion_poller_t::loop, and onion_poller_t::stop.