-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathengine.h
More file actions
82 lines (66 loc) · 1.93 KB
/
Copy pathengine.h
File metadata and controls
82 lines (66 loc) · 1.93 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once
#include <stdint.h>
#include <pthread.h>
#include "segment.h"
#include "atomic.h"
#include "queue.h"
#include "task.h"
#include "merger.h"
#include "lib/utlist.h"
#define ERROR_CODE_SUCCESS 0
#define ERROR_CODE_INVALID_ARGUMENT -1
#define ERROR_CODE_QUEUE_FULL -2
typedef struct _ts_engine ts_engine_t;
struct _ts_engine {
/**
* 所有的段,双向链表结构
*/
ts_segment_t *segments;
/**
* 当前活动的段
* 接受正在写入
*/
ts_segment_t *segment_active;
ts_queue_t input_queue;
pthread_t input_processor;
pthread_t lookup_processor;
pthread_t merger_thread;
ts_merger_t *merger;
/**
* 子线程退出标记位
*/
volatile uint32_t exit;
int (*start)(struct _ts_engine *engine);
void (*shutdown)(struct _ts_engine *engine);
int (*add)(struct _ts_engine *engine, ts_document_t *doc);
int (*remove)(struct _ts_engine *engine, uint64_t pk);
int (*lookup)(struct _ts_engine *engine, ts_lookup_request_t *request,
ts_lookup_response_t *response);
};
ts_engine_t *ts_engine_new();
void ts_engine_free(ts_engine_t *engine);
typedef struct {
ts_engine_t *engine;
ts_document_t *doc;
} ts_task_document_add_args_t;
typedef struct {
ts_engine_t *engine;
uint64_t pk;
} ts_task_document_remove_args_t;
#define ts_task_document_add_args_new() ({ \
ts_task_document_add_args_t *__args = \
ts_calloc(1, sizeof(ts_task_document_add_args_t)); \
assert(__args != NULL); \
__args; \
})
#define ts_task_document_add_args_free(a) (ts_free(a))
#define ts_task_document_remove_args_new() ({ \
ts_task_document_remove_args_t *__args = \
ts_calloc(1, sizeof(ts_task_document_remove_args_t)); \
assert(__args != NULL); \
__args; \
})
#define ts_task_document_remove_args_free(a) (ts_free(a))
#ifdef _DEBUG
void ts_engine_print(ts_engine_t *engine);
#endif