1 #ifndef __RK_LIST_H__ 2 #define __RK_LIST_H__ 3 4 #include <pthread.h> 5 #include "rk_type.h" 6 // desctructor of list node 7 typedef void *(*node_destructor)(void *); 8 9 struct rk_list_node; 10 class rk_list 11 { 12 public: 13 rk_list(node_destructor func); 14 ~rk_list(); 15 16 // for FIFO or FILO implement 17 // adding functions support simple structure like C struct or C++ class pointer, 18 // do not support C++ object 19 RK_S32 add_at_head(void *data, RK_S32 size); 20 RK_S32 add_at_tail(void *data, RK_S32 size); 21 // deleting function will copy the stored data to input pointer with size as size 22 // if NULL is passed to deleting functions, the node will be delete directly 23 RK_S32 del_at_head(void *data, RK_S32 size); 24 RK_S32 del_at_tail(void *data, RK_S32 size); 25 26 // for status check 27 RK_S32 list_is_empty(); 28 RK_S32 list_size(); 29 30 // for vector implement - not implemented yet 31 // adding function will return a key 32 RK_S32 add_by_key(void *data, RK_S32 size, RK_U32 *key); 33 RK_S32 del_by_key(void *data, RK_S32 size, RK_U32 key); 34 RK_S32 show_by_key(void *data, RK_U32 key); 35 36 RK_S32 flush(); 37 38 private: 39 pthread_mutex_t mutex; 40 node_destructor destroy; 41 struct rk_list_node *head; 42 RK_S32 count; 43 44 rk_list(); 45 rk_list(const rk_list &); 46 rk_list &operator=(const rk_list &); 47 }; 48 49 #endif /*__RK_LIST_H__*/ 50