blob: 4815a4c73b084302c810b1faf0d0e679c650759a (
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
|
#ifndef ENGINE_THREADS_H
#define ENGINE_THREADS_H
#include <pthread.h>
#include <stdatomic.h>
#include "bitboard.h"
#include "ipc/engine_message.h"
#include "ipc/go_args.h"
struct thread_args {
// signal sent by threads manager
atomic_int stop;
// signal sent by thread
atomic_int finished;
int id;
position_t *position;
go_args_t *go_args;
engine_message_handler_t *message;
};
struct threads {
pthread_t *threads;
struct thread_args *args;
size_t count;
size_t capacity;
int running_count;
engine_messages_t *engine_messages;
go_args_t *go_args;
position_t *position;
};
#ifdef ENGINE_THREADS_INTERNAL
void __threads_args_init(
struct thread_args* args,
struct threads *handler,
int i
);
#endif
void threads_init(struct threads *handler, size_t capacity);
void threads_deinit(struct threads *handler);
void threads_reserve(struct threads *handler, size_t capacity);
void threads_go(struct threads *handler);
bool threads_go_loop(struct threads *handler);
bool threads_all_done(struct threads *handler);
void threads_cleanup(struct threads *handler);
void *engine_thread(void *args);
#endif // ENGINE_THREADS_H
|