diff options
author | Sergiusz Bazanski <q3k@q3k.org> | 2018-07-20 13:15:22 +0100 |
---|---|---|
committer | Sergiusz Bazanski <q3k@q3k.org> | 2018-07-20 13:15:22 +0100 |
commit | b4b111a053a5e2aacd036508899277022914ae8f (patch) | |
tree | 405b15fc7133b82497a2a0c361c3c17015c3be16 /common/nextpnr.h | |
parent | b84a446eeff080715ba0b4b98c14822f0e3f8530 (diff) | |
download | nextpnr-b4b111a053a5e2aacd036508899277022914ae8f.tar.gz nextpnr-b4b111a053a5e2aacd036508899277022914ae8f.tar.bz2 nextpnr-b4b111a053a5e2aacd036508899277022914ae8f.zip |
Move pthread yield hack into BaseCtx
Diffstat (limited to 'common/nextpnr.h')
-rw-r--r-- | common/nextpnr.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h index 1f75434d..e9cda565 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -20,6 +20,7 @@ #include <algorithm> #include <assert.h> +#include <condition_variable> #include <memory> #include <mutex> #include <pthread.h> @@ -346,8 +347,9 @@ class BaseCtx : public IdStringDB { private: std::mutex mutex; - bool mutex_owned; pthread_t mutex_owner; + + std::mutex generation_mutex; public: std::unordered_map<IdString, std::unique_ptr<NetInfo>> nets; @@ -360,6 +362,7 @@ class BaseCtx : public IdStringDB { mutex.lock(); mutex_owner = pthread_self(); + } void unlock(void) @@ -368,6 +371,14 @@ class BaseCtx : public IdStringDB mutex.unlock(); } + // TODO(q3k): get rid of this hack + void yield(void) + { + for (int i = 0; i < 10; i++) { + pthread_yield(); + } + } + Context *getCtx() { return reinterpret_cast<Context *>(this); } const Context *getCtx() const { return reinterpret_cast<const Context *>(this); } |