-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread.h
More file actions
54 lines (42 loc) · 1.37 KB
/
thread.h
File metadata and controls
54 lines (42 loc) · 1.37 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
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (C) 2024-2025, Shu De Zheng <imchuncai@gmail.com>. All Rights Reserved.
#ifndef __UMEM_CACHE_THREAD_H
#define __UMEM_CACHE_THREAD_H
#include "conn.h"
#include "hash_table.h"
#include "kv_cache.h"
#include "fixed_mem_cache.h"
#define KV_CACHE_LEN 75
#define THREAD_MAX_CONN (CONFIG_MAX_CONN / CONFIG_THREAD_NR)
#define THREAD_MAX_MEM ((uint64_t)CONFIG_MEM_LIMIT / CONFIG_THREAD_NR)
static_assert(THREAD_MAX_CONN <= INT32_MAX);
/**
* thread -
* @epfd: the epoll file descriptor that manages IO events for this thread
* @__warmed_up: used for cluster growth. we call thread is warmed up once we
* reclaim memory from it, be aware of main thread will read it.
* @memory: memory manager
* @lru_head: lru of all enabled kv
* @hash_table: hash table used to index kv or conn
* @kv_cache_list: the list of kv_cache manages memory for kv and concat_val
*/
struct thread {
int epfd;
#ifdef CONFIG_RAFT
bool __warmed_up;
#endif
struct memory memory;
struct list_head lru_head;
struct hash_table hash_table;
struct hlist_head clock_list;
struct kv_cache kv_cache_list[KV_CACHE_LEN];
struct fixed_mem_cache conn_cache;
struct conn __conns[THREAD_MAX_CONN];
struct epoll_event events[THREAD_MAX_CONN];
};
bool threads_run();
void thread_dispatch(uint32_t id, int sockfd);
#ifdef CONFIG_RAFT
bool threads_warmed_up();
#endif
#endif