mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Adds a way to get the native handle from SafeThread (#198)
Useful to wpilib to enable easier changing of RT priorities.
This commit is contained in:
committed by
Peter Johnson
parent
9a2ec13ba4
commit
067b1f3ee0
@@ -82,9 +82,13 @@ class SafeThreadOwnerBase {
|
||||
protected:
|
||||
void Start(SafeThread* thr);
|
||||
SafeThread* GetThread() const { return m_thread.load(); }
|
||||
std::thread::native_handle_type GetNativeThreadHandle() const {
|
||||
return m_nativeHandle;
|
||||
}
|
||||
|
||||
private:
|
||||
std::atomic<SafeThread*> m_thread;
|
||||
std::atomic<std::thread::native_handle_type> m_nativeHandle;
|
||||
};
|
||||
|
||||
inline void SafeThreadOwnerBase::Start(SafeThread* thr) {
|
||||
@@ -94,10 +98,12 @@ inline void SafeThreadOwnerBase::Start(SafeThread* thr) {
|
||||
delete newthr;
|
||||
return;
|
||||
}
|
||||
std::thread([=]() {
|
||||
std::thread stdThread([=]() {
|
||||
newthr->Main();
|
||||
delete newthr;
|
||||
}).detach();
|
||||
});
|
||||
m_nativeHandle = stdThread.native_handle();
|
||||
stdThread.detach();
|
||||
}
|
||||
|
||||
inline void SafeThreadOwnerBase::Stop() {
|
||||
|
||||
Reference in New Issue
Block a user