Skip to content

Commit be77406

Browse files
committed
Get rid of nativeThread
No functional change.
1 parent 26dabb1 commit be77406

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/endgame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ eg_type = typename std::conditional<(E < SCALING_FUNCTIONS), Value, ScaleFactor>
7676
template<typename T>
7777
struct EndgameBase {
7878

79-
virtual ~EndgameBase() {}
79+
virtual ~EndgameBase() = default;
8080
virtual Color strong_side() const = 0;
8181
virtual T operator()(const Position&) const = 0;
8282
};

src/thread.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ namespace {
3838
// when start_routine (and hence virtual idle_loop) is called and when joining.
3939

4040
template<typename T> T* new_thread() {
41-
T* th = new T();
42-
th->nativeThread = std::thread(&ThreadBase::idle_loop, th); // Will go to sleep
43-
return th;
41+
std::thread* th = new T;
42+
*th = std::thread(&T::idle_loop, (T*)th); // Will go to sleep
43+
return (T*)th;
4444
}
4545

4646
void delete_thread(ThreadBase* th) {
@@ -50,7 +50,7 @@ namespace {
5050
th->mutex.unlock();
5151

5252
th->notify_one();
53-
th->nativeThread.join(); // Wait for thread termination
53+
th->join(); // Wait for thread termination
5454
delete th;
5555
}
5656

@@ -61,7 +61,7 @@ namespace {
6161

6262
void ThreadBase::notify_one() {
6363

64-
std::unique_lock<Mutex>(this->mutex);
64+
std::unique_lock<Mutex> lk(mutex);
6565
sleepCondition.notify_one();
6666
}
6767

src/thread.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,13 @@ struct SplitPoint {
8989
/// ThreadBase struct is the base of the hierarchy from where we derive all the
9090
/// specialized thread classes.
9191

92-
struct ThreadBase {
92+
struct ThreadBase : public std::thread {
9393

9494
virtual ~ThreadBase() = default;
9595
virtual void idle_loop() = 0;
9696
void notify_one();
9797
void wait_for(volatile const bool& b);
9898

99-
std::thread nativeThread;
10099
Mutex mutex;
101100
Spinlock spinlock;
102101
ConditionVariable sleepCondition;

src/uci.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace {
6868
return;
6969

7070
pos.set(fen, Options["UCI_Chess960"], Threads.main());
71-
SetupStates = Search::StateStackPtr(new std::stack<StateInfo>());
71+
SetupStates = Search::StateStackPtr(new std::stack<StateInfo>);
7272

7373
// Parse move list (if any)
7474
while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE)

0 commit comments

Comments
 (0)