|
libonion
|
#include <ev.h>#include <stdlib.h>#include <semaphore.h>#include "poller.h"#include "log.h"#include "low.h"Data Structures | |
| struct | onion_poller_t |
| Manages the polling on a set of file descriptors. More... | |
| struct | onion_poller_slot_t |
| Data about a poller element: timeout, function to call shutdown function. | |
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, int 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 *p) |
| Frees the poller. It first stops it. | |
| int | onion_poller_add (onion_poller *poller, onion_poller_slot *el) |
| Adds a slot to the poller. | |
| int | onion_poller_remove (onion_poller *poller, int fd) |
| Removes a fd from the poller. | |
| onion_poller_slot * | onion_poller_get (onion_poller *poller, int fd) |
| Gets the poller to do some modifications as change shutdown. | |
| void | onion_poller_poll (onion_poller *poller) |
| Do the polling. If on several threads, this is done in every thread. | |
| void | onion_poller_stop (onion_poller *poller) |
| Stops the polling. This only marks the flag, and should be cancelled with pthread_cancel. | |
| 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.
References onion_poller_t::loop.
| void onion_poller_free | ( | onion_poller * | p | ) |
Frees the poller. It first stops it.
References onion_low_free().
| onion_poller* onion_poller_new | ( | int | aprox_n | ) |
Create a new poller.
References onion_poller_t::loop, onion_low_calloc(), and onion_poller_t::sem.
| void onion_poller_poll | ( | onion_poller * | poller | ) |
Do the polling. If on several threads, this is done in every thread.
References 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_slot_set_type | ( | onion_poller_slot * | el, |
| int | type | ||
| ) |
Sets the polling type: read/write/other. O_POLL_READ | O_POLL_WRITE | O_POLL_OTHER.
References O_POLL_READ, and O_POLL_WRITE.
| void onion_poller_stop | ( | onion_poller * | poller | ) |
Stops the polling. This only marks the flag, and should be cancelled with pthread_cancel.
References onion_poller_t::loop, and onion_poller_t::stop.
1.8.1.2