-
Notifications
You must be signed in to change notification settings - Fork 0
/
safe_rw_list.h
executable file
·63 lines (44 loc) · 1.33 KB
/
safe_rw_list.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by root on 18-7-24.
//
#ifndef QOS_SAFE_RW_LIST_H
#define QOS_SAFE_RW_LIST_H
#include "list_head.h"
#include "memory_cache.h"
#include "sysqos_common.h"
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SAFE_RW_LIST_TEST
enum
{
safe_rw_list_error_ok,
safe_rw_list_error_notfound,
safe_rw_list_error_initlock,
safe_rw_list_error_exist,
};
typedef struct safe_rw_list
{
int (*insert)(struct safe_rw_list *list, void *id, void *pri);
int (*erase)(struct safe_rw_list *list, void *id, void **pri);
int (*find)(struct safe_rw_list *list, void *id, void **pri);
void (*set_compare)(struct safe_rw_list *list, compare_id_func compare);
void (*for_each_do)(struct safe_rw_list *list,void *ctx, for_each_dofunc_t dofunc);
/***********************************************************/
#ifdef SAFE_RW_LIST_TEST
void (*dump)(struct safe_rw_list *list);
#endif
/******************************************************/
compare_id_func compare;
memory_cache_t *cache;
struct list_head list;
pthread_rwlock_t rwlock;
} safe_rw_list_t;
int safe_rw_list_init(safe_rw_list_t *list, memory_cache_t *item_cache);
void safe_rw_list_exit(safe_rw_list_t *list);
void test_safe_rw_list();
#ifdef __cplusplus
}
#endif
#endif //TEST_QOS_SAFE_RW_LIST_H