forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
threading.h
68 lines (50 loc) · 1.27 KB
/
threading.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
64
65
66
67
68
// This file is a part of Julia. License is MIT: http://julialang.org/license
#ifndef THREADING_H
#define THREADING_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "threadgroup.h"
#include "julia.h"
#define PROFILE_JL_THREADING 1
// thread ID
#define ti_tid (jl_get_ptls_states()->tid)
extern jl_thread_task_state_t *jl_all_task_states;
extern JL_DLLEXPORT int jl_n_threads; // # threads we're actually using
#ifdef JULIA_ENABLE_THREADING
// GC
extern struct _jl_thread_heap_t **jl_all_heaps;
#endif
// thread state
enum {
TI_THREAD_INIT,
TI_THREAD_WORK
};
// passed to thread function
typedef struct {
int16_t volatile state;
int16_t tid;
ti_threadgroup_t *tg;
} ti_threadarg_t;
// commands to thread function
enum {
TI_THREADWORK_DONE,
TI_THREADWORK_RUN
};
// work command to thread function
typedef struct {
uint8_t command;
jl_function_t *fun;
jl_svec_t *args;
jl_value_t *ret;
jl_module_t *current_module;
} ti_threadwork_t;
// thread function
void ti_threadfun(void *arg);
// helpers for thread function
jl_value_t *ti_runthread(jl_function_t *f, jl_svec_t *args, size_t nargs);
#ifdef __cplusplus
}
#endif
#endif /* THREADING_H */