Teonet library
0.4.7
|
Macros | |
#define | kev ((ksnetEvMgrClass*)(kq->ke)) |
#define | cq ((ksnCQueData*)(w->data)) |
#define | kev2 ((ksnetEvMgrClass*)(cq->kq->ke)) |
Functions | |
ksnCQueClass * | ksnCQueInit (void *ke, uint8_t send_event) |
Initialize ksnCQue module class. More... | |
void | ksnCQueDestroy (ksnCQueClass *kq) |
Destroy ksnCQue module class. More... | |
int | ksnCQueExec (ksnCQueClass *kq, uint32_t id) |
Execute callback queue record. More... | |
int | ksnCQueRemove (ksnCQueClass *kq, uint32_t id) |
Remove callback from queue. More... | |
int | ksnCQueSetData (ksnCQueClass *kq, uint32_t id, void *data) |
Set callback queue data, update data set in ksnCQueAdd. More... | |
void * | ksnCQueGetData (ksnCQueClass *kq, uint32_t id) |
Get callback queue data. More... | |
void | cq_timer_cb (EV_P_ ev_timer *w, int revents) |
Callback Queue timeout timer callback. More... | |
ksnCQueData * | ksnCQueAdd (ksnCQueClass *kq, ksnCQueCallback cb, double timeout, void *data) |
Add callback to queue. More... | |
void * | ksnCQueFindData (ksnCQueClass *kq, void *find, ksnCQueCompare compare, size_t *key_length) |
Find data in CQue. More... | |
void * | pblMapRemoveFree (PblMap *map, void *key, size_t keyLength, size_t *valueLengthPtr) |
Removes the mapping for this key from this map if it is present. More... | |
Callback QUEUE used to organize async calls to any functions.
See example: teocque.c
See test: test_cque.c
Created on August 21, 2015, 12:10 PM
#define cq ((ksnCQueData*)(w->data)) |
Referenced by cq_timer_cb(), event_cb(), get_cb(), ksnCoreCheckNewPeer(), ksnCQueAdd(), ksnCQueExec(), ksnCQueGetData(), ksnCQueRemove(), ksnCQueSetData(), peer_type_cb(), teo::Teonet::TeoDB::send(), test_4_2(), and test_4_3().
#define kev ((ksnetEvMgrClass*)(kq->ke)) |
Referenced by ksnCQueAdd(), ksnCQueExec(), and ksnCQueRemove().
#define kev2 ((ksnetEvMgrClass*)(cq->kq->ke)) |
Referenced by cq_timer_cb().
void cq_timer_cb | ( | EV_P_ ev_timer * | w, |
int | revents | ||
) |
Callback Queue timeout timer callback.
w | Event manager loop and watcher |
revents | Reserved (not used) |
References cq, EV_K_CQUE_CALLBACK, kev2, and pblMapRemoveFree().
Referenced by ksnCQueAdd().
ksnCQueData* ksnCQueAdd | ( | ksnCQueClass * | kq, |
ksnCQueCallback | cb, | ||
double | timeout, | ||
void * | data | ||
) |
Add callback to queue.
kq | Pointer to ksnCQueClass |
cb | Callback function or NULL. The teonet event EV_K_CQUE_CALLBACK should be send at the same time. |
timeout | Callback timeout. If equal to 0 than timeout sets automatically |
data | The user data which should be send to the Callback function |
References ksnCQueData::cb, cq, cq_timer_cb(), ksnCQueClass::cque_map, data, ksnCQueData::data, ksnCQueClass::id, ksnCQueData::id, kev, ksnCQueData::kq, ksnCQueData::timeout, and ksnCQueData::w.
Referenced by _check_connected(), teo::Teonet::CQue::add(), event_cb(), get_cb(), ksnCoreCheckNewPeer(), ksnStreamCreate(), peer_type_cb(), test_4_2(), and test_4_3().
void ksnCQueDestroy | ( | ksnCQueClass * | kq | ) |
Destroy ksnCQue module class.
kq | Pointer to ksnCQueClass |
References ksnCQueClass::cque_map, and free().
Referenced by modules_destroy(), test_4_1(), test_4_2(), test_4_3(), and teo::Teonet::CQue::~CQue().
int ksnCQueExec | ( | ksnCQueClass * | kq, |
uint32_t | id | ||
) |
Execute callback queue record.
Get callback queue record and remove it from queue
kq | Pointer to ksnCQueClass |
id | Required ID |
References ksnCQueData::cb, cq, ksnCQueClass::cque_map, ksnCQueData::data, EV_K_CQUE_CALLBACK, ksnCQueClass::event_f, kev, ksnCQueData::kq, pblMapRemoveFree(), ksnCQueData::timeout, and ksnCQueData::w.
Referenced by event_cb(), teo::Teonet::CQue::exec(), ksnStreamCreate(), and test_4_3().
void* ksnCQueFindData | ( | ksnCQueClass * | kq, |
void * | find, | ||
ksnCQueCompare | compare, | ||
size_t * | key_length | ||
) |
Find data in CQue.
kq | Pointer to ksnCQueClass |
find | Pointer to data to find |
compare | Callback compare function int compare(void* find, void* data) which return pointer to key if data find or NULL in other way |
key_length | [out] Pointer to key_length variable or NULL if not need it |
References ksnCQueClass::cque_map, data, and ksnCQueData::data.
Referenced by teo::Teonet::CQue::find().
void* ksnCQueGetData | ( | ksnCQueClass * | kq, |
uint32_t | id | ||
) |
Get callback queue data.
kq | Pointer to ksnCQueClass |
id | Existing callback queue ID |
References cq, ksnCQueClass::cque_map, and ksnCQueData::data.
Referenced by teo::Teonet::CQue::getCQueData(), and teo::Teonet::CQue::setUserData().
ksnCQueClass* ksnCQueInit | ( | void * | ke, |
uint8_t | send_event | ||
) |
Initialize ksnCQue module class.
ke | Pointer to ksnetEvMgrClass |
send_event | Send cque event if true |
References ksnCQueClass::cque_map, ksnCQueClass::event_f, ksnCQueClass::id, ksnCQueClass::ke, ke, and malloc().
Referenced by modules_init(), test_4_1(), test_4_2(), and test_4_3().
int ksnCQueRemove | ( | ksnCQueClass * | kq, |
uint32_t | id | ||
) |
Remove callback from queue.
kq | Pointer to ksnCQueClass |
id | Required ID |
References cq, ksnCQueClass::cque_map, kev, pblMapRemoveFree(), ksnCQueData::timeout, and ksnCQueData::w.
Referenced by teo::Teonet::CQue::remove().
int ksnCQueSetData | ( | ksnCQueClass * | kq, |
uint32_t | id, | ||
void * | data | ||
) |
Set callback queue data, update data set in ksnCQueAdd.
kq | Pointer to ksnCQueClass |
id | Existing callback queue ID |
data | Pointer to callback queue records data |
References cq, ksnCQueClass::cque_map, data, and ksnCQueData::data.
void* pblMapRemoveFree | ( | PblMap * | map, |
void * | key, | ||
size_t | keyLength, | ||
size_t * | valueLengthPtr | ||
) |
Removes the mapping for this key from this map if it is present.
map | |
key | |
keyLength | |
valueLengthPtr |
!= | NULL && != (void*)-1: successfully removed |
== | NULL: there was no mapping for key |
== | (void*)-1: An error, see pbl_errno: PBL_ERROR_OUT_OF_MEMORY - Out of memory. |
References free().
Referenced by cq_timer_cb(), ksnCQueExec(), ksnCQueRemove(), ksnLNullClientDisconnect(), ksnSplitCombine(), ksnStreamClose(), and ksnTCPProxyServerClientDisconnect().