mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-23 21:27:14 +00:00
Clean up comments in code
- Capitalize comments - Reformat multi-lines comments to equalize the widths of the lines - Try to keep the width of comments around 85 characters - Remove periods at the end of single-line comments closes https://github.com/official-stockfish/Stockfish/pull/5469 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
98a7bb4436
commit
7e72b37e4c
+15
-16
@@ -50,8 +50,8 @@ Thread::Thread(Search::SharedState& sharedState,
|
||||
|
||||
run_custom_job([this, &binder, &sharedState, &sm, n]() {
|
||||
// Use the binder to [maybe] bind the threads to a NUMA node before doing
|
||||
// the Worker allocation.
|
||||
// Ideally we would also allocate the SearchManager here, but that's minor.
|
||||
// the Worker allocation. Ideally we would also allocate the SearchManager
|
||||
// here, but that's minor.
|
||||
this->numaAccessToken = binder();
|
||||
this->worker =
|
||||
std::make_unique<Search::Worker>(sharedState, std::move(sm), n, this->numaAccessToken);
|
||||
@@ -72,27 +72,26 @@ Thread::~Thread() {
|
||||
stdThread.join();
|
||||
}
|
||||
|
||||
|
||||
// Wakes up the thread that will start the search
|
||||
void Thread::start_searching() {
|
||||
assert(worker != nullptr);
|
||||
run_custom_job([this]() { worker->start_searching(); });
|
||||
}
|
||||
|
||||
// Wakes up the thread that will start the search
|
||||
// Clears the histories for the thread worker (usually before a new game)
|
||||
void Thread::clear_worker() {
|
||||
assert(worker != nullptr);
|
||||
run_custom_job([this]() { worker->clear(); });
|
||||
}
|
||||
|
||||
// Blocks on the condition variable
|
||||
// until the thread has finished searching.
|
||||
// Blocks on the condition variable until the thread has finished searching
|
||||
void Thread::wait_for_search_finished() {
|
||||
|
||||
std::unique_lock<std::mutex> lk(mutex);
|
||||
cv.wait(lk, [&] { return !searching; });
|
||||
}
|
||||
|
||||
// Launching a function in the thread
|
||||
void Thread::run_custom_job(std::function<void()> f) {
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(mutex);
|
||||
@@ -103,8 +102,8 @@ void Thread::run_custom_job(std::function<void()> f) {
|
||||
cv.notify_one();
|
||||
}
|
||||
|
||||
// Thread gets parked here, blocked on the
|
||||
// condition variable, when it has no work to do.
|
||||
// Thread gets parked here, blocked on the condition variable
|
||||
// when the thread has no work to do.
|
||||
|
||||
void Thread::idle_loop() {
|
||||
while (true)
|
||||
@@ -233,8 +232,9 @@ void ThreadPool::wait_on_thread(size_t threadId) {
|
||||
|
||||
size_t ThreadPool::num_threads() const { return threads.size(); }
|
||||
|
||||
// Wakes up main thread waiting in idle_loop() and
|
||||
// returns immediately. Main thread will wake up other threads and start the search.
|
||||
|
||||
// Wakes up main thread waiting in idle_loop() and returns immediately.
|
||||
// Main thread will wake up other threads and start the search.
|
||||
void ThreadPool::start_thinking(const OptionsMap& options,
|
||||
Position& pos,
|
||||
StateListPtr& states,
|
||||
@@ -274,8 +274,8 @@ void ThreadPool::start_thinking(const OptionsMap& options,
|
||||
// We use Position::set() to set root position across threads. But there are
|
||||
// some StateInfo fields (previous, pliesFromNull, capturedPiece) that cannot
|
||||
// be deduced from a fen string, so set() clears them and they are set from
|
||||
// setupStates->back() later. The rootState is per thread, earlier states are shared
|
||||
// since they are read-only.
|
||||
// setupStates->back() later. The rootState is per thread, earlier states are
|
||||
// shared since they are read-only.
|
||||
for (auto&& th : threads)
|
||||
{
|
||||
th->run_custom_job([&]() {
|
||||
@@ -335,7 +335,7 @@ Thread* ThreadPool::get_best_thread() const {
|
||||
const bool newThreadInProvenLoss =
|
||||
newThreadScore != -VALUE_INFINITE && newThreadScore <= VALUE_TB_LOSS_IN_MAX_PLY;
|
||||
|
||||
// Note that we make sure not to pick a thread with truncated-PV for better viewer experience.
|
||||
// We make sure not to pick a thread with truncated principal variation
|
||||
const bool betterVotingValue =
|
||||
thread_voting_value(th.get()) * int(newThreadPV.size() > 2)
|
||||
> thread_voting_value(bestThread) * int(bestThreadPV.size() > 2);
|
||||
@@ -363,8 +363,8 @@ Thread* ThreadPool::get_best_thread() const {
|
||||
}
|
||||
|
||||
|
||||
// Start non-main threads
|
||||
// Will be invoked by main thread after it has started searching
|
||||
// Start non-main threads.
|
||||
// Will be invoked by main thread after it has started searching.
|
||||
void ThreadPool::start_searching() {
|
||||
|
||||
for (auto&& th : threads)
|
||||
@@ -374,7 +374,6 @@ void ThreadPool::start_searching() {
|
||||
|
||||
|
||||
// Wait for non-main threads
|
||||
|
||||
void ThreadPool::wait_for_search_finished() const {
|
||||
|
||||
for (auto&& th : threads)
|
||||
|
||||
Reference in New Issue
Block a user