BenBot
1.7.5
A chess engine
Loading...
Searching...
No Matches
Thread.hpp
Go to the documentation of this file.
1
/*
2
* ======================================================================================
3
*
4
* ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
5
* ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
6
* ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
7
* ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
8
* ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
9
* ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
10
* ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
11
*
12
* ======================================================================================
13
*/
14
19
20
#pragma once
21
22
#include <atomic>
23
#include <chrono>
24
#include <
libbenbot/search/Callbacks.hpp
>
25
#include <
libbenbot/search/Context.hpp
>
26
#include <
libchess/game/Position.hpp
>
27
#include <thread>
28
29
namespace
chess::uci
{
30
struct
GoCommandOptions
;
31
}
// namespace chess::uci
32
33
namespace
ben_bot::search
{
34
35
using
std::chrono::milliseconds;
36
41
struct
Thread
final {
43
Thread
() =
default
;
44
48
explicit
Thread
(
Callbacks
&& callbacksToUse);
49
50
~Thread
();
51
52
Thread
(
const
Thread
&) =
delete
;
53
Thread
&
operator=
(
const
Thread
&) =
delete
;
54
Thread
(
Thread
&&) =
delete
;
55
Thread
&
operator=
(
Thread
&&) =
delete
;
56
61
Context
context
;
62
67
void
start
()
68
{
69
context
.wait();
// shouldn't have been searching, but better safe than sorry
70
71
startSearch.store(
true
, std::memory_order::release);
72
}
73
74
private
:
75
void
thread_func();
76
77
std::thread searcherThread { [
this
] { thread_func(); } };
78
79
std::atomic_bool threadShouldExit {
false
};
80
std::atomic_bool startSearch {
false
};
81
};
82
83
}
// namespace ben_bot::search
Callbacks.hpp
Context.hpp
Position.hpp
ben_bot::search
Definition
TranspositionTable.hpp:42
chess::uci
Definition
CommandParsing.hpp:43
ben_bot::search::Callbacks
Definition
Callbacks.hpp:41
ben_bot::search::Context
Definition
Context.hpp:41
ben_bot::search::Thread::operator=
Thread & operator=(const Thread &)=delete
ben_bot::search::Thread::operator=
Thread & operator=(Thread &&)=delete
ben_bot::search::Thread::~Thread
~Thread()
ben_bot::search::Thread::Thread
Thread(Thread &&)=delete
ben_bot::search::Thread::Thread
Thread(const Thread &)=delete
ben_bot::search::Thread::context
Context context
Definition
Thread.hpp:61
ben_bot::search::Thread::start
void start()
Definition
Thread.hpp:67
ben_bot::search::Thread::Thread
Thread(Callbacks &&callbacksToUse)
ben_bot::search::Thread::Thread
Thread()=default
chess::uci::GoCommandOptions
Definition
CommandParsing.hpp:92
libbenbot
include
libbenbot
search
Thread.hpp
Generated on
for BenBot by
1.16.1