Skip to content

Commit

Permalink
C++11 patchset 3: remove Atomic/GenericAtomic and use std::atomic (#5906
Browse files Browse the repository at this point in the history
)
  • Loading branch information
nerzhul committed Jun 6, 2017
1 parent a6678d6 commit b3dfe53
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 149 deletions.
6 changes: 3 additions & 3 deletions src/environment.h
Expand Up @@ -33,11 +33,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <list>
#include <queue>
#include <map>
#include <atomic>
#include "irr_v3d.h"
#include "activeobject.h"
#include "util/numeric.h"
#include "threading/mutex.h"
#include "threading/atomic.h"
#include "network/networkprotocol.h" // for AccessDeniedCode

class IGameDef;
Expand Down Expand Up @@ -81,7 +81,7 @@ class Environment
IGameDef *getGameDef() { return m_gamedef; }

protected:
GenericAtomic<float> m_time_of_day_speed;
std::atomic<float> m_time_of_day_speed;

/*
* Below: values managed by m_time_lock
Expand All @@ -98,7 +98,7 @@ class Environment
u32 m_day_night_ratio_override;
// Days from the server start, accounts for time shift
// in game (e.g. /time or bed usage)
Atomic<u32> m_day_count;
std::atomic<u32> m_day_count;
/*
* Above: values managed by m_time_lock
*/
Expand Down
139 changes: 0 additions & 139 deletions src/threading/atomic.h

This file was deleted.

7 changes: 4 additions & 3 deletions src/threading/thread.h
Expand Up @@ -27,11 +27,12 @@ DEALINGS IN THE SOFTWARE.
#define THREADING_THREAD_H

#include "util/basic_macros.h"
#include "threading/atomic.h"
#include "threading/mutex.h"
#include "threads.h"

#include <string>
#include <atomic>

#ifdef _AIX
#include <sys/thread.h> // for tid_t
#endif
Expand Down Expand Up @@ -150,8 +151,8 @@ class Thread {
private:
void *m_retval;
bool m_joinable;
Atomic<bool> m_request_stop;
Atomic<bool> m_running;
std::atomic<bool> m_request_stop;
std::atomic<bool> m_running;
Mutex m_mutex;
Mutex m_start_finished_mutex;

Expand Down
8 changes: 4 additions & 4 deletions src/unittest/test_threading.cpp
Expand Up @@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#include "test.h"

#include "threading/atomic.h"
#include <atomic>
#include "threading/semaphore.h"
#include "threading/thread.h"

Expand Down Expand Up @@ -137,7 +137,7 @@ void TestThreading::testThreadKill()

class AtomicTestThread : public Thread {
public:
AtomicTestThread(Atomic<u32> &v, Semaphore &trigger) :
AtomicTestThread(std::atomic<u32> &v, Semaphore &trigger) :
Thread("AtomicTest"),
val(v),
trigger(trigger)
Expand All @@ -153,14 +153,14 @@ class AtomicTestThread : public Thread {
return NULL;
}

Atomic<u32> &val;
std::atomic<u32> &val;
Semaphore &trigger;
};


void TestThreading::testAtomicSemaphoreThread()
{
Atomic<u32> val;
std::atomic<u32> val;
val = 0;
Semaphore trigger;
static const u8 num_threads = 4;
Expand Down

0 comments on commit b3dfe53

Please sign in to comment.