mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 14:27:45 +00:00
Clarify the behaviour of execute_with_worker[s]
This commit is contained in:
+1
-2
@@ -186,8 +186,7 @@ void ThreadPool::clear() {
|
|||||||
main()->previousTimeReduction = 1.0;
|
main()->previousTimeReduction = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThreadPool::execute_with_workers(const std::function<void(Thread&)>& worker)
|
||||||
void ThreadPool::execute_with_workers(std::function<void(Thread&)> worker)
|
|
||||||
{
|
{
|
||||||
for(Thread* th : *this)
|
for(Thread* th : *this)
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-1
@@ -52,7 +52,13 @@ public:
|
|||||||
explicit Thread(size_t);
|
explicit Thread(size_t);
|
||||||
virtual ~Thread();
|
virtual ~Thread();
|
||||||
virtual void search();
|
virtual void search();
|
||||||
|
|
||||||
|
// The function object to be executed is taken by value to remove
|
||||||
|
// the need for separate lvalue and rvalue overloads.
|
||||||
|
// The worker thread needs to have ownership of the task
|
||||||
|
// to be executed because otherwise there's no way to manage its lifetime.
|
||||||
virtual void execute_with_worker(std::function<void(Thread&)> t);
|
virtual void execute_with_worker(std::function<void(Thread&)> t);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void idle_loop();
|
void idle_loop();
|
||||||
void start_searching();
|
void start_searching();
|
||||||
@@ -109,7 +115,10 @@ struct MainThread : public Thread {
|
|||||||
|
|
||||||
struct ThreadPool : public std::vector<Thread*> {
|
struct ThreadPool : public std::vector<Thread*> {
|
||||||
|
|
||||||
void execute_with_workers(std::function<void(Thread&)> worker);
|
// Each thread gets its own copy of the `worker` function object.
|
||||||
|
// This means that each worker thread will have exclusive access
|
||||||
|
// to the state of the `worker` function object.
|
||||||
|
void execute_with_workers(const std::function<void(Thread&)>& worker);
|
||||||
|
|
||||||
void start_thinking(Position&, StateListPtr&, const Search::LimitsType&, bool = false);
|
void start_thinking(Position&, StateListPtr&, const Search::LimitsType&, bool = false);
|
||||||
void clear();
|
void clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user