5#ifndef WPIUTIL_WPI_SAFETHREAD_H_
6#define WPIUTIL_WPI_SAFETHREAD_H_
57 explicit operator bool()
const {
return m_thread !=
nullptr; }
102 explicit operator bool()
const;
109 void Start(std::shared_ptr<SafeThreadBase> thr);
114 std::thread m_stdThread;
115 std::weak_ptr<SafeThreadBase> m_thread;
116 std::atomic_bool m_joinAtExit{
true};
126 template <
typename... Args>
129 std::make_shared<T>(std::forward<Args>(args)...));
138 return std::static_pointer_cast<T>(
An atomic signaling event for synchronization.
Definition: Synchronization.h:250
Base class for SafeThreadOwner threads.
Definition: SafeThread.h:22
virtual ~SafeThreadBase()=default
std::thread::id m_threadId
Definition: SafeThread.h:30
std::atomic_bool m_active
Definition: SafeThread.h:29
wpi::mutex m_mutex
Definition: SafeThread.h:28
Definition: SafeThread.h:40
SafeThreadEvent()
Definition: SafeThread.h:42
Event m_stopEvent
Definition: SafeThread.h:46
Definition: SafeThread.h:33
wpi::condition_variable m_cond
Definition: SafeThread.h:37
Definition: SafeThread.h:124
void Start(Args &&... args)
Definition: SafeThread.h:127
Proxy GetThread() const
Definition: SafeThread.h:133
typename detail::SafeThreadProxy< T > Proxy
Definition: SafeThread.h:132
std::shared_ptr< T > GetThreadSharedPtr() const
Definition: SafeThread.h:137
Non-template owner base class for common owner code.
Definition: SafeThread.h:82
void SetJoinAtExit(bool joinAtExit)
Definition: SafeThread.h:106
void Start(std::shared_ptr< SafeThreadBase > thr)
SafeThreadOwnerBase & operator=(SafeThreadOwnerBase &&other) noexcept
Definition: SafeThread.h:94
SafeThreadOwnerBase() noexcept=default
friend void swap(SafeThreadOwnerBase &lhs, SafeThreadOwnerBase &rhs) noexcept
std::thread::native_handle_type GetNativeThreadHandle()
std::shared_ptr< SafeThreadBase > GetThreadSharedPtr() const
Non-template proxy base class for common proxy code.
Definition: SafeThread.h:54
std::unique_lock< wpi::mutex > & GetLock()
Definition: SafeThread.h:58
std::shared_ptr< SafeThreadBase > m_thread
Definition: SafeThread.h:61
SafeThreadProxyBase(std::shared_ptr< SafeThreadBase > thr)
std::unique_lock< wpi::mutex > m_lock
Definition: SafeThread.h:62
A proxy for SafeThread.
Definition: SafeThread.h:71
T * operator->() const
Definition: SafeThread.h:76
SafeThreadProxy(std::shared_ptr< SafeThreadBase > thr)
Definition: SafeThread.h:73
T & operator*() const
Definition: SafeThread.h:75
detail namespace with internal helper functions
Definition: xchar.h:20
void swap(SafeThreadOwnerBase &lhs, SafeThreadOwnerBase &rhs) noexcept
Definition: ntcore_cpp.h:26
::std::condition_variable condition_variable
Definition: condition_variable.h:16
::std::mutex mutex
Definition: mutex.h:17