mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 09:13:08 +00:00
Move wake_sleeping_thread() to Thread class
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
2c317d7b28
commit
79e50a2fbf
2 changed files with 10 additions and 16 deletions
|
@ -76,7 +76,6 @@ namespace {
|
||||||
bool available_thread_exists(int master) const;
|
bool available_thread_exists(int master) const;
|
||||||
bool thread_is_available(int slave, int master) const;
|
bool thread_is_available(int slave, int master) const;
|
||||||
bool cutoff_at_splitpoint(int threadID) const;
|
bool cutoff_at_splitpoint(int threadID) const;
|
||||||
void wake_sleeping_thread(int threadID);
|
|
||||||
void idle_loop(int threadID, SplitPoint* sp);
|
void idle_loop(int threadID, SplitPoint* sp);
|
||||||
|
|
||||||
template <bool Fake>
|
template <bool Fake>
|
||||||
|
@ -509,7 +508,7 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
|
||||||
// Wake up needed threads and reset maxPly counter
|
// Wake up needed threads and reset maxPly counter
|
||||||
for (int i = 0; i < ThreadsMgr.active_threads(); i++)
|
for (int i = 0; i < ThreadsMgr.active_threads(); i++)
|
||||||
{
|
{
|
||||||
ThreadsMgr.wake_sleeping_thread(i);
|
ThreadsMgr[i].wake_up();
|
||||||
ThreadsMgr[i].maxPly = 0;
|
ThreadsMgr[i].maxPly = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2107,7 +2106,7 @@ split_point_start: // At split points actual search starts from here
|
||||||
// Wake up master thread so to allow it to return from the idle loop in
|
// Wake up master thread so to allow it to return from the idle loop in
|
||||||
// case we are the last slave of the split point.
|
// case we are the last slave of the split point.
|
||||||
if (useSleepingThreads && threadID != tsp->master && threads[tsp->master].state == THREAD_AVAILABLE)
|
if (useSleepingThreads && threadID != tsp->master && threads[tsp->master].state == THREAD_AVAILABLE)
|
||||||
wake_sleeping_thread(tsp->master);
|
threads[tsp->master].wake_up();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this thread is the master of a split point and all slaves have
|
// If this thread is the master of a split point and all slaves have
|
||||||
|
@ -2201,7 +2200,7 @@ split_point_start: // At split points actual search starts from here
|
||||||
// Wake up all the threads and waits for termination
|
// Wake up all the threads and waits for termination
|
||||||
for (int i = 1; i < MAX_THREADS; i++)
|
for (int i = 1; i < MAX_THREADS; i++)
|
||||||
{
|
{
|
||||||
wake_sleeping_thread(i);
|
threads[i].wake_up();
|
||||||
while (threads[i].state != THREAD_TERMINATED) {}
|
while (threads[i].state != THREAD_TERMINATED) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2376,7 +2375,7 @@ split_point_start: // At split points actual search starts from here
|
||||||
threads[i].state = THREAD_WORKISWAITING; // This makes the slave to exit from idle_loop()
|
threads[i].state = THREAD_WORKISWAITING; // This makes the slave to exit from idle_loop()
|
||||||
|
|
||||||
if (useSleepingThreads && i != master)
|
if (useSleepingThreads && i != master)
|
||||||
wake_sleeping_thread(i);
|
threads[i].wake_up();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything is set up. The master thread enters the idle loop, from
|
// Everything is set up. The master thread enters the idle loop, from
|
||||||
|
@ -2400,17 +2399,6 @@ split_point_start: // At split points actual search starts from here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// wake_sleeping_thread() wakes up the thread with the given threadID
|
|
||||||
// when it is time to start a new search.
|
|
||||||
|
|
||||||
void ThreadsManager::wake_sleeping_thread(int threadID) {
|
|
||||||
|
|
||||||
lock_grab(&threads[threadID].sleepLock);
|
|
||||||
cond_signal(&threads[threadID].sleepCond);
|
|
||||||
lock_release(&threads[threadID].sleepLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// RootMove and RootMoveList method's definitions
|
/// RootMove and RootMoveList method's definitions
|
||||||
|
|
||||||
RootMove::RootMove() {
|
RootMove::RootMove() {
|
||||||
|
|
|
@ -75,6 +75,12 @@ struct Thread {
|
||||||
SplitPoint* volatile splitPoint;
|
SplitPoint* volatile splitPoint;
|
||||||
volatile int activeSplitPoints;
|
volatile int activeSplitPoints;
|
||||||
SplitPoint splitPoints[MAX_ACTIVE_SPLIT_POINTS];
|
SplitPoint splitPoints[MAX_ACTIVE_SPLIT_POINTS];
|
||||||
|
|
||||||
|
void wake_up() {
|
||||||
|
lock_grab(&sleepLock);
|
||||||
|
cond_signal(&sleepCond);
|
||||||
|
lock_release(&sleepLock);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(THREAD_H_INCLUDED)
|
#endif // !defined(THREAD_H_INCLUDED)
|
||||||
|
|
Loading…
Add table
Reference in a new issue