summaryrefslogtreecommitdiff
path: root/src/thread/thread.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2019-03-11 00:45:39 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-06 11:27:39 +0200
commit05f4e7360886e36b221ef5c3af4426625a3de686 (patch)
tree27aed9756e80eca86ff95f5805901a80048b0fb1 /src/thread/thread.h
parent3b86f54fc739510277f434c68e17a93ab6448ed4 (diff)
downloadopenttd-05f4e7360886e36b221ef5c3af4426625a3de686.tar.xz
Codechange: Replace custom mutex code with C++11 mutex'es.
A conforming compiler with a valid <mutex>-header is expected. Most parts of the code assume that locking a mutex will never fail unexpectedly, which is generally true on all common platforms that don't just pretend to be C++11. The use of condition variables in driver code is checked.
Diffstat (limited to 'src/thread/thread.h')
-rw-r--r--src/thread/thread.h67
1 files changed, 0 insertions, 67 deletions
diff --git a/src/thread/thread.h b/src/thread/thread.h
index 07831bb4b..eca825e25 100644
--- a/src/thread/thread.h
+++ b/src/thread/thread.h
@@ -51,73 +51,6 @@ public:
};
/**
- * Cross-platform Mutex
- */
-class ThreadMutex {
-public:
- /**
- * Create a new mutex.
- */
- static ThreadMutex *New();
-
- /**
- * Virtual Destructor to avoid compiler warnings.
- */
- virtual ~ThreadMutex() {};
-
- /**
- * Begin the critical section
- * @param allow_recursive Whether recursive locking is intentional.
- * If false, NOT_REACHED() will be called when the mutex is already locked
- * by the current thread.
- */
- virtual void BeginCritical(bool allow_recursive = false) = 0;
-
- /**
- * End of the critical section
- * @param allow_recursive Whether recursive unlocking is intentional.
- * If false, NOT_REACHED() will be called when the mutex was locked more
- * than once by the current thread.
- */
- virtual void EndCritical(bool allow_recursive = false) = 0;
-
- /**
- * Wait for a signal to be send.
- * @pre You must be in the critical section.
- * @note While waiting the critical section is left.
- * @post You will be in the critical section.
- */
- virtual void WaitForSignal() = 0;
-
- /**
- * Send a signal and wake the 'thread' that was waiting for it.
- */
- virtual void SendSignal() = 0;
-};
-
-/**
- * Simple mutex locker to keep a mutex locked until the locker goes out of scope.
- */
-class ThreadMutexLocker {
-public:
- /**
- * Lock the mutex and keep it locked for the life time of this object.
- * @param mutex Mutex to be locked.
- */
- ThreadMutexLocker(ThreadMutex *mutex) : mutex(mutex) { mutex->BeginCritical(); }
-
- /**
- * Unlock the mutex.
- */
- ~ThreadMutexLocker() { this->mutex->EndCritical(); }
-
-private:
- ThreadMutexLocker(const ThreadMutexLocker &) { NOT_REACHED(); }
- ThreadMutexLocker &operator=(const ThreadMutexLocker &) { NOT_REACHED(); return *this; }
- ThreadMutex *mutex;
-};
-
-/**
* Get number of processor cores in the system, including HyperThreading or similar.
* @return Total number of processor cores.
*/