Teonet library
0.4.7
|
#include <ev.h>
#include <pbl.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | ksnCQueClass |
ksnCQue Class structure definition More... | |
struct | ksnCQueData |
ksnCQue data structure More... | |
Typedefs | |
typedef struct ksnCQueClass | ksnCQueClass |
ksnCQue Class structure definition More... | |
typedef void(* | ksnCQueCallback )(uint32_t id, int type, void *data) |
ksnCQue callback function definition More... | |
typedef struct ksnCQueData | ksnCQueData |
ksnCQue data structure More... | |
typedef int(* | ksnCQueCompare )(void *find, void *data) |
Find data in CQueue callback function. More... | |
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... | |
void * | ksnCQueGetData (ksnCQueClass *kq, uint32_t id) |
Get callback queue data. More... | |
int | ksnCQueSetData (ksnCQueClass *kq, uint32_t id, void *data) |
Set callback queue data, update data set in ksnCQueAdd. More... | |
ksnCQueData * | ksnCQueAdd (ksnCQueClass *kq, ksnCQueCallback cb, double timeout, void *data) |
Add callback to queue. More... | |
int | ksnCQueRemove (ksnCQueClass *kq, uint32_t id) |
Remove callback from 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... | |
typedef void(* ksnCQueCallback)(uint32_t id, int type, void *data) |
ksnCQue callback function definition
id | Calls ID |
type | Type: 0 - timeout callback; 1 - successful callback |
data | User data selected in ksnCQueAdd() function |
typedef struct ksnCQueClass ksnCQueClass |
ksnCQue Class structure definition
typedef int(* ksnCQueCompare)(void *find, void *data) |
Find data in CQueue callback function.
typedef struct ksnCQueData ksnCQueData |
ksnCQue data structure
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().