blob: 77cff00dc8d78015920bcddb0fdbbbbbd812ec2c (
plain)
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
|
/*-
* Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
* See the file LICENSE for redistribution information.
*/
/*
* WT_THREAD --
* Encapsulation of a thread that belongs to a thread group.
*/
struct __wt_thread {
WT_SESSION_IMPL *session;
u_int id;
wt_thread_t tid;
/*
* WT_THREAD and thread-group function flags, merged because
* WT_THREAD_PANIC_FAIL appears in both groups.
*/
#define WT_THREAD_CAN_WAIT 0x01 /* WT_SESSION_CAN_WAIT */
#define WT_THREAD_PANIC_FAIL 0x02 /* panic if the thread fails */
#define WT_THREAD_RUN 0x04 /* thread is running */
uint32_t flags;
/* The runner function used by all threads. */
int (*run_func)(WT_SESSION_IMPL *session, WT_THREAD *context);
};
/*
* WT_THREAD_GROUP --
* Encapsulation of a group of utility threads.
*/
struct __wt_thread_group {
uint32_t alloc; /* Size of allocated group */
uint32_t max; /* Max threads in group */
uint32_t min; /* Min threads in group */
uint32_t current_threads;/* Number of active threads */
const char *name; /* Name */
WT_RWLOCK lock; /* Protects group changes */
/*
* Condition signalled when wanting to wake up threads that are
* part of the group - for example when shutting down. This condition
* can also be used by group owners to ensure state changes are noticed.
*/
WT_CONDVAR *wait_cond;
/*
* The threads need to be held in an array of arrays, not an array of
* structures because the array is reallocated as it grows, which
* causes threads to loose track of their context is realloc moves the
* memory.
*/
WT_THREAD **threads;
/* The runner function used by all threads. */
int (*run_func)(WT_SESSION_IMPL *session, WT_THREAD *context);
};
|