Make thread check portable
This commit is contained in:
parent
8b60ed5fd1
commit
5e58a329e6
@ -23,10 +23,10 @@
|
|||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <pthread.h>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -344,7 +344,7 @@ struct BaseCtx
|
|||||||
{
|
{
|
||||||
// Lock to perform mutating actions on the Context.
|
// Lock to perform mutating actions on the Context.
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
pthread_t mutex_owner;
|
std::thread::id mutex_owner;
|
||||||
|
|
||||||
// Lock to be taken by UI when wanting to access context - the yield()
|
// Lock to be taken by UI when wanting to access context - the yield()
|
||||||
// method will lock/unlock it when its' released the main mutex to make
|
// method will lock/unlock it when its' released the main mutex to make
|
||||||
@ -377,12 +377,12 @@ struct BaseCtx
|
|||||||
void lock(void)
|
void lock(void)
|
||||||
{
|
{
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
mutex_owner = pthread_self();
|
mutex_owner = std::this_thread::get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
void unlock(void)
|
void unlock(void)
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(pthread_equal(pthread_self(), mutex_owner) != 0);
|
NPNR_ASSERT(std::this_thread::get_id() != mutex_owner);
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user