diff options
author | Josh Blum | 2012-10-11 22:43:14 -0700 |
---|---|---|
committer | Josh Blum | 2012-10-11 22:43:14 -0700 |
commit | 4aa36c6aaaab4a5ae8eed1d81a46c1d09d32a258 (patch) | |
tree | 4450a1e3b9b29a5348e0f713ececfa7803e179ed /lib/block_actor.cpp | |
parent | 83d855d2e88e631cbb607841f985e294b2f0845d (diff) | |
download | sandhi-4aa36c6aaaab4a5ae8eed1d81a46c1d09d32a258.tar.gz sandhi-4aa36c6aaaab4a5ae8eed1d81a46c1d09d32a258.tar.bz2 sandhi-4aa36c6aaaab4a5ae8eed1d81a46c1d09d32a258.zip |
make use of new yield strategy for framework param
Diffstat (limited to 'lib/block_actor.cpp')
-rw-r--r-- | lib/block_actor.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/lib/block_actor.cpp b/lib/block_actor.cpp index e522624..108e7d3 100644 --- a/lib/block_actor.cpp +++ b/lib/block_actor.cpp @@ -21,6 +21,15 @@ using namespace gnuradio; +ThreadPoolConfig::ThreadPoolConfig(void) +{ + thread_count = boost::thread::hardware_concurrency(); + thread_count = std::max(size_t(2), thread_count); + node_mask = 0; + processor_mask = 0xffffffff; + yield_strategy = "STRONG"; +} + /*********************************************************************** * Thread pool implementation **********************************************************************/ @@ -35,26 +44,19 @@ ThreadPool::ThreadPool(boost::weak_ptr<Theron::Framework> p): //NOP } -const size_t default_concurrency(void) -{ - const size_t n = boost::thread::hardware_concurrency(); - return std::max(size_t(2), n); -} - -ThreadPool::ThreadPool(unsigned long threadCount) +ThreadPool::ThreadPool(const ThreadPoolConfig &config) { - if (threadCount == 0) threadCount = default_concurrency(); - this->reset(new Theron::Framework(Theron::Framework::Parameters(threadCount, 0))); -} + Theron::Framework::Parameters params( + config.thread_count, + config.node_mask, + config.processor_mask + ); -ThreadPool::ThreadPool(const unsigned long threadCount, const unsigned long nodeMask) -{ - this->reset(new Theron::Framework(Theron::Framework::Parameters(threadCount, nodeMask))); -} + if (config.yield_strategy == "POLITE") params.mYieldStrategy = Theron::Framework::YIELD_STRATEGY_POLITE; + if (config.yield_strategy == "STRONG") params.mYieldStrategy = Theron::Framework::YIELD_STRATEGY_STRONG; + if (config.yield_strategy == "AGGRESSIVE") params.mYieldStrategy = Theron::Framework::YIELD_STRATEGY_AGGRESSIVE; -ThreadPool::ThreadPool(const unsigned long threadCount, const unsigned long nodeMask, const unsigned long processorMask) -{ - this->reset(new Theron::Framework(Theron::Framework::Parameters(threadCount, nodeMask, processorMask))); + this->reset(new Theron::Framework(Theron::Framework::Parameters(params))); } /*********************************************************************** @@ -73,7 +75,7 @@ static ThreadPool get_active_thread_pool(void) { if (not weak_framework.lock()) { - active_thread_pool = ThreadPool(0); + active_thread_pool = ThreadPool(ThreadPoolConfig()); active_thread_pool.set_active(); std::cout << "Created default thread pool with " << active_thread_pool->GetNumThreads() << " threads." << std::endl; } |