Skip to content

Commit b3dfe53

Browse files
authoredJun 6, 2017
C++11 patchset 3: remove Atomic/GenericAtomic and use std::atomic (#5906)
1 parent a6678d6 commit b3dfe53

File tree

4 files changed

+11
-149
lines changed

4 files changed

+11
-149
lines changed
 

‎src/environment.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3333
#include <list>
3434
#include <queue>
3535
#include <map>
36+
#include <atomic>
3637
#include "irr_v3d.h"
3738
#include "activeobject.h"
3839
#include "util/numeric.h"
3940
#include "threading/mutex.h"
40-
#include "threading/atomic.h"
4141
#include "network/networkprotocol.h" // for AccessDeniedCode
4242

4343
class IGameDef;
@@ -81,7 +81,7 @@ class Environment
8181
IGameDef *getGameDef() { return m_gamedef; }
8282

8383
protected:
84-
GenericAtomic<float> m_time_of_day_speed;
84+
std::atomic<float> m_time_of_day_speed;
8585

8686
/*
8787
* Below: values managed by m_time_lock
@@ -98,7 +98,7 @@ class Environment
9898
u32 m_day_night_ratio_override;
9999
// Days from the server start, accounts for time shift
100100
// in game (e.g. /time or bed usage)
101-
Atomic<u32> m_day_count;
101+
std::atomic<u32> m_day_count;
102102
/*
103103
* Above: values managed by m_time_lock
104104
*/

‎src/threading/atomic.h

-139
This file was deleted.

‎src/threading/thread.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ DEALINGS IN THE SOFTWARE.
2727
#define THREADING_THREAD_H
2828

2929
#include "util/basic_macros.h"
30-
#include "threading/atomic.h"
3130
#include "threading/mutex.h"
3231
#include "threads.h"
3332

3433
#include <string>
34+
#include <atomic>
35+
3536
#ifdef _AIX
3637
#include <sys/thread.h> // for tid_t
3738
#endif
@@ -150,8 +151,8 @@ class Thread {
150151
private:
151152
void *m_retval;
152153
bool m_joinable;
153-
Atomic<bool> m_request_stop;
154-
Atomic<bool> m_running;
154+
std::atomic<bool> m_request_stop;
155+
std::atomic<bool> m_running;
155156
Mutex m_mutex;
156157
Mutex m_start_finished_mutex;
157158

‎src/unittest/test_threading.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
1919

2020
#include "test.h"
2121

22-
#include "threading/atomic.h"
22+
#include <atomic>
2323
#include "threading/semaphore.h"
2424
#include "threading/thread.h"
2525

@@ -137,7 +137,7 @@ void TestThreading::testThreadKill()
137137

138138
class AtomicTestThread : public Thread {
139139
public:
140-
AtomicTestThread(Atomic<u32> &v, Semaphore &trigger) :
140+
AtomicTestThread(std::atomic<u32> &v, Semaphore &trigger) :
141141
Thread("AtomicTest"),
142142
val(v),
143143
trigger(trigger)
@@ -153,14 +153,14 @@ class AtomicTestThread : public Thread {
153153
return NULL;
154154
}
155155

156-
Atomic<u32> &val;
156+
std::atomic<u32> &val;
157157
Semaphore &trigger;
158158
};
159159

160160

161161
void TestThreading::testAtomicSemaphoreThread()
162162
{
163-
Atomic<u32> val;
163+
std::atomic<u32> val;
164164
val = 0;
165165
Semaphore trigger;
166166
static const u8 num_threads = 4;

0 commit comments

Comments
 (0)
Please sign in to comment.