X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=dc50686381fa5531db1055d79c8f04b3f58f703c;hp=a6899de9cbff793b9650ac4b30029c72f4ec20b5;hb=13a73f67c018e58b2fd46f886c45ef2b75188c8e;hpb=500b9b0eb3b20ef58ff1280a089ab2ef1e3c6436 diff --git a/src/thread.cpp b/src/thread.cpp index a6899de9..dc506863 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -38,7 +38,7 @@ namespace { // Helpers to launch a thread after creation and joining before delete. Must be - // outside Thread c'tor and d'tor because object shall be fully initialized + // outside Thread c'tor and d'tor because the object will be fully initialized // when start_routine (and hence virtual idle_loop) is called and when joining. template T* new_thread() { @@ -77,8 +77,8 @@ void ThreadBase::wait_for(volatile const bool& b) { } -// Thread c'tor just inits data but does not launch any thread of execution that -// instead will be started only upon c'tor returns. +// Thread c'tor just inits data and does not launch any execution thread. +// Such a thread will only be started when c'tor returns. Thread::Thread() /* : splitPoints() */ { // Value-initialization bug in MSVC @@ -112,7 +112,7 @@ void TimerThread::idle_loop() { // MainThread::idle_loop() is where the main thread is parked waiting to be started -// when there is a new search. Main thread will launch all the slave threads. +// when there is a new search. The main thread will launch all the slave threads. void MainThread::idle_loop() { @@ -124,7 +124,7 @@ void MainThread::idle_loop() { while (!thinking && !exit) { - Threads.sleepCondition.notify_one(); // Wake up UI thread if needed + Threads.sleepCondition.notify_one(); // Wake up the UI thread if needed sleepCondition.wait(mutex); } @@ -170,7 +170,7 @@ bool Thread::available_to(const Thread* master) const { return false; // Make a local copy to be sure doesn't become zero under our feet while - // testing next condition and so leading to an out of bound access. + // testing next condition and so leading to an out of bounds access. int size = splitPointsSize; // No split points means that the thread is available as a slave for any @@ -206,8 +206,9 @@ void ThreadPool::exit() { // read_uci_options() updates internal threads parameters from the corresponding // UCI options and creates/destroys threads to match the requested number. Thread -// objects are dynamically allocated to avoid creating in advance all possible -// threads, with included pawns and material tables, if only few are used. +// objects are dynamically allocated to avoid creating all possible threads +// in advance (which include pawns and material tables), even if only a few +// are to be used. void ThreadPool::read_uci_options() { @@ -323,8 +324,9 @@ void Thread::split(Position& pos, const Stack* ss, Value alpha, Value beta, Valu Thread::idle_loop(); // Force a call to base class idle_loop() - // In helpful master concept a master can help only a sub-tree of its split - // point, and because here is all finished is not possible master is booked. + // In the helpful master concept, a master can help only a sub-tree of its + // split point and because everything is finished here, it's not possible + // for the master to be booked. assert(!searching); assert(!activePosition);