diff options
author | Josh Blum | 2013-03-17 14:19:24 -0700 |
---|---|---|
committer | Josh Blum | 2013-03-17 14:19:24 -0700 |
commit | 61f2af4f8287665d91478575793399043e6c00f7 (patch) | |
tree | 5425d32643ab1a87fc8fa692a9d7ac2b72c912a3 /lib/gras_impl/block_actor.hpp | |
parent | cebd974738fea792f70bca8ab0bb1d73e2116d81 (diff) | |
download | sandhi-61f2af4f8287665d91478575793399043e6c00f7.tar.gz sandhi-61f2af4f8287665d91478575793399043e6c00f7.tar.bz2 sandhi-61f2af4f8287665d91478575793399043e6c00f7.zip |
gras: helper function for high prio hack
Diffstat (limited to 'lib/gras_impl/block_actor.hpp')
-rw-r--r-- | lib/gras_impl/block_actor.hpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/gras_impl/block_actor.hpp b/lib/gras_impl/block_actor.hpp index 935c87d..d088254 100644 --- a/lib/gras_impl/block_actor.hpp +++ b/lib/gras_impl/block_actor.hpp @@ -32,7 +32,22 @@ struct BlockActor : Apology::Worker ThreadPool thread_pool; //! Priority count to hack in high-prio worker queue - Theron::Detail::Atomic::UInt32 prio_count; + Theron::Detail::Atomic::UInt32 prioCount; + GRAS_FORCE_INLINE void highPrioPreNotify(void) + { + this->prioCount.Increment(); + } + GRAS_FORCE_INLINE void highPrioAck(void) + { + ASSERT(this->prioCount.Load() != 0); + this->prioCount.Decrement(); + this->handle_task(); + } + GRAS_FORCE_INLINE bool hasHighPrioMsg(void) + { + //high prio when the count is positive and there are enqueued messages (avoids race) + return this->prioCount.Load() and this->GetNumQueuedMessages(); + } //do it here so we can match w/ the handler declarations void register_handlers(void) @@ -120,10 +135,8 @@ struct BlockActor : Apology::Worker GRAS_FORCE_INLINE bool is_work_allowed(void) { - //high prio when the count is positive and there are enqueued messages (avoids race) - const bool has_high_prio_msg = this->prio_count.Load() and this->GetNumQueuedMessages(); return ( - not has_high_prio_msg and + not this->hasHighPrioMsg() and this->block_state == BLOCK_STATE_LIVE and this->input_queues.all_ready() and this->inputs_available.any() and |