Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cque.h
Go to the documentation of this file.
1 /*
2  * File: cque.h
3  * Author: Kirill Scherba <kirill@scherba.ru>
4  *
5  * Created on August 21, 2015, 12:10 PM
6  */
7 
8 #ifndef CQUE_H
9 #define CQUE_H
10 
11 #include <ev.h>
12 #include <pbl.h>
13 #include <stdint.h>
14 
18 typedef struct ksnCQueClass {
19 
20  void *ke;
21  uint32_t id;
22  PblMap *cque_map;
23  uint8_t event_f;
24 
25 } ksnCQueClass;
26 
34 typedef void (*ksnCQueCallback) (uint32_t id, int type, void *data);
35 
39 typedef struct ksnCQueData {
40 
43  double timeout;
44  uint32_t id;
45  //char data[]; ///< \todo: Some data
46  void *data;
47  ev_timer w;
48 
49 } ksnCQueData;
50 
54 typedef int (*ksnCQueCompare) (void *find, void *data);
55 
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 ksnCQueClass *ksnCQueInit(void *ke, uint8_t send_event);
63 
64 int ksnCQueExec(ksnCQueClass *kq, uint32_t id);
65 void * ksnCQueGetData(ksnCQueClass *kq, uint32_t id);
66 int ksnCQueSetData(ksnCQueClass *kq, uint32_t id, void *data);
67 ksnCQueData *ksnCQueAdd(ksnCQueClass *kq, ksnCQueCallback cb, double timeout,
68  void *data);
69 int ksnCQueRemove(ksnCQueClass *kq, uint32_t id);
70 void *ksnCQueFindData(ksnCQueClass *kq, void* find, ksnCQueCompare compare, size_t *key_length);
71 
72 void *pblMapRemoveFree(PblMap * map, void * key, size_t keyLength,
73  size_t * valueLengthPtr );
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif /* CQUE_H */
ksnCQueClass * kq
Pointer to ksnCQueClass.
Definition: cque.h:42
PblMap * cque_map
Pointer to the callback queue pblMap.
Definition: cque.h:22
uint32_t id
New callback queue ID.
Definition: cque.h:21
uint32_t id
Callback ID (equal to key)
Definition: cque.h:44
const char data[]
Make it with: gcc -o post-callback post-callback.c -lcurl.
Definition: post-callback.c:23
ev_timer w
Timeout watcher.
Definition: cque.h:47
double timeout
Timeout value.
Definition: cque.h:43
void * ksnCQueGetData(ksnCQueClass *kq, uint32_t id)
Get callback queue data.
Definition: cque.c:200
void * data
User data.
Definition: cque.h:46
uint8_t event_f
Send cque event if true.
Definition: cque.h:23
int ksnCQueRemove(ksnCQueClass *kq, uint32_t id)
Remove callback from queue.
Definition: cque.c:147
void * ksnCQueFindData(ksnCQueClass *kq, void *find, ksnCQueCompare compare, size_t *key_length)
Find data in CQue.
Definition: cque.c:301
ksnCQue Class structure definition
Definition: cque.h:18
void(* ksnCQueCallback)(uint32_t id, int type, void *data)
ksnCQue callback function definition
Definition: cque.h:34
void * ke
Pointer to ksnEvMgrClass.
Definition: cque.h:20
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.
Definition: cque.c:333
int ksnCQueSetData(ksnCQueClass *kq, uint32_t id, void *data)
Set callback queue data, update data set in ksnCQueAdd.
Definition: cque.c:178
void ksnCQueDestroy(ksnCQueClass *kq)
Destroy ksnCQue module class.
Definition: cque.c:88
ksnCQueData * ksnCQueAdd(ksnCQueClass *kq, ksnCQueCallback cb, double timeout, void *data)
Add callback to queue.
Definition: cque.c:260
#define ke
ksnCQueCallback cb
Pointer to callback function.
Definition: cque.h:41
ksnCQueClass * ksnCQueInit(void *ke, uint8_t send_event)
Initialize ksnCQue module class.
Definition: cque.c:43
ksnCQue data structure
Definition: cque.h:39
int ksnCQueExec(ksnCQueClass *kq, uint32_t id)
Execute callback queue record.
Definition: cque.c:106
struct ksnCQueData ksnCQueData
ksnCQue data structure
struct ksnCQueClass ksnCQueClass
ksnCQue Class structure definition
int(* ksnCQueCompare)(void *find, void *data)
Find data in CQueue callback function.
Definition: cque.h:54