Fixed autoconf macros for cross compile
[awesomized/libmemcached] / clients / ms_task.h
1 /*
2 * File: ms_task.h
3 * Author: Mingqiang Zhuang
4 *
5 * Created on February 10, 2009
6 *
7 * (c) Copyright 2009, Schooner Information Technology, Inc.
8 * http://www.schoonerinfotech.com/
9 *
10 */
11 #ifndef MS_TASK_H
12 #define MS_TASK_H
13
14 #include <sys/types.h>
15 #include <stdint.h>
16 #if !defined(__cplusplus)
17 # include <stdbool.h>
18 #endif
19 #include <time.h>
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 #define UNIT_ITEMS_COUNT 1024 /* each window unit has 1024 items */
26 #define KEY_PREFIX_SIZE (sizeof(uint64_t)) /* key prefix length: 8 bytes */
27 #define INVALID_OFFSET (-1) /* invalid offset in the character table */
28 #define FIXED_EXPIRE_TIME 60 /* default expire time is 60s */
29 #define EXPIRE_TIME_ERROR 5 /* default expire time error is 5s */
30
31 /* information of a task item(object) */
32 typedef struct task_item
33 {
34 uint64_t key_prefix; /* prefix of the key, 8 bytes, binary */
35 int key_size; /* key size */
36 int key_suffix_offset; /* suffix offset in the global character table */
37
38 int value_size; /* data size */
39 int value_offset; /* data offset in the global character table */
40
41 time_t client_time; /* the current client time */
42 int exp_time; /* expire time */
43 } ms_task_item_t;
44
45 /* task item for multi-get */
46 typedef struct mlget_task_item
47 {
48 ms_task_item_t *item; /* task item */
49 bool verify; /* whether verify data or not */
50 bool finish_verify; /* whether finish data verify or not */
51 bool get_miss; /* whether get miss or not */
52 } ms_mlget_task_item_t;
53
54 /* information of multi-get task */
55 typedef struct mlget_task
56 {
57 ms_mlget_task_item_t *mlget_item; /* multi-get task array */
58 int mlget_num; /* how many tasks in mlget_task array */
59 int value_index; /* the nth value received by the connect, for multi-get */
60 } ms_mlget_task_t;
61
62 /* structure used to store the state of the running task */
63 typedef struct task
64 {
65 int cmd; /* command name */
66 bool verify; /* whether verify data or not */
67 bool finish_verify; /* whether finish data verify or not */
68 bool get_miss; /* whether get miss or not */
69 ms_task_item_t *item; /* task item */
70
71 /* counter for command distribution adjustment */
72 uint64_t get_opt; /* number of total get operations */
73 uint64_t set_opt; /* number of total set operations, no including warmup set count */
74 int cycle_undo_get; /* number of undo get in an adjustment cycle */
75 int cycle_undo_set; /* number of undo set in an adjustment cycle */
76 uint64_t verified_get; /* number of total verified get operations */
77 uint64_t overwrite_set; /* number of total overwrite set operations */
78 } ms_task_t;
79
80 struct conn;
81
82 /* the state machine call the function to execute task.*/
83 int ms_exec_task(struct conn *c);
84
85
86 /* calculate the difference value of two time points */
87 int64_t ms_time_diff(struct timeval *start_time, struct timeval *end_time);
88
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* end of MS_TASK_H */