Allow execution of tasks on the global thread pool.

This commit is contained in:
Tomasz Sobczyk
2020-10-17 23:26:29 +02:00
committed by nodchip
parent 146a6b056e
commit 5188c26b20
3 changed files with 37 additions and 2 deletions

View File

@@ -24,6 +24,7 @@
#include <mutex>
#include <thread>
#include <vector>
#include <functional>
#include "material.h"
#include "movepick.h"
@@ -50,10 +51,12 @@ public:
explicit Thread(size_t);
virtual ~Thread();
virtual void search();
virtual void execute_task(std::function<void(Thread&)> t);
void clear();
void idle_loop();
void start_searching();
void wait_for_search_finished();
size_t thread_idx() const { return idx; }
Pawns::Table pawnsTable;
Material::Table materialTable;
@@ -78,6 +81,7 @@ public:
bool UseRule50;
Depth ProbeDepth;
std::function<void(Thread&)> task;
};
@@ -105,6 +109,8 @@ struct MainThread : public Thread {
struct ThreadPool : public std::vector<Thread*> {
void execute_parallel(std::function<void(Thread&)> task);
void start_thinking(Position&, StateListPtr&, const Search::LimitsType&, bool = false);
void clear();
void set(size_t);