mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Use wpi mutex and condition_variable. (#52)
This commit is contained in:
@@ -9,10 +9,11 @@
|
||||
#define WPIUTIL_SUPPORT_SAFETHREAD_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#include "support/condition_variable.h"
|
||||
#include "support/mutex.h"
|
||||
|
||||
namespace wpi {
|
||||
|
||||
// Base class for SafeThreadOwner threads.
|
||||
@@ -22,9 +23,9 @@ class SafeThread {
|
||||
virtual ~SafeThread() = default;
|
||||
virtual void Main() = 0;
|
||||
|
||||
std::mutex m_mutex;
|
||||
wpi::mutex m_mutex;
|
||||
std::atomic_bool m_active;
|
||||
std::condition_variable m_cond;
|
||||
wpi::condition_variable m_cond;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
@@ -42,11 +43,11 @@ class SafeThreadProxyBase {
|
||||
}
|
||||
}
|
||||
explicit operator bool() const { return m_thread != nullptr; }
|
||||
std::unique_lock<std::mutex>& GetLock() { return m_lock; }
|
||||
std::unique_lock<wpi::mutex>& GetLock() { return m_lock; }
|
||||
|
||||
protected:
|
||||
SafeThread* m_thread;
|
||||
std::unique_lock<std::mutex> m_lock;
|
||||
std::unique_lock<wpi::mutex> m_lock;
|
||||
};
|
||||
|
||||
// A proxy for SafeThread.
|
||||
|
||||
Reference in New Issue
Block a user