summaryrefslogtreecommitdiff
path: root/lib/block_actor.cpp
diff options
context:
space:
mode:
authorJosh Blum2012-10-07 01:14:35 -0700
committerJosh Blum2012-10-07 01:14:35 -0700
commit5fe747d0cd2776eabc0ece6a95993f403a854f23 (patch)
tree5fc248982154c7cbb5cf2efdf00428f170a22437 /lib/block_actor.cpp
parentfcf2261594e4bbc084c757e975e536428b4a2d0d (diff)
downloadsandhi-5fe747d0cd2776eabc0ece6a95993f403a854f23.tar.gz
sandhi-5fe747d0cd2776eabc0ece6a95993f403a854f23.tar.bz2
sandhi-5fe747d0cd2776eabc0ece6a95993f403a854f23.zip
better naive defaults for thread pool
Diffstat (limited to 'lib/block_actor.cpp')
-rw-r--r--lib/block_actor.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/block_actor.cpp b/lib/block_actor.cpp
index 0b0199b..e522624 100644
--- a/lib/block_actor.cpp
+++ b/lib/block_actor.cpp
@@ -16,6 +16,7 @@
#include <gnuradio/thread_pool.hpp>
#include <gras_impl/block_actor.hpp>
+#include <boost/thread/thread.hpp>
#include <Theron/Framework.h>
using namespace gnuradio;
@@ -34,10 +35,16 @@ ThreadPool::ThreadPool(boost::weak_ptr<Theron::Framework> p):
//NOP
}
-ThreadPool::ThreadPool(const unsigned long threadCount)
+const size_t default_concurrency(void)
{
- if (threadCount == 0) this->reset(new Theron::Framework(Theron::Framework::Parameters()));
- else this->reset(new Theron::Framework(Theron::Framework::Parameters(threadCount)));
+ const size_t n = boost::thread::hardware_concurrency();
+ return std::max(size_t(2), n);
+}
+
+ThreadPool::ThreadPool(unsigned long threadCount)
+{
+ if (threadCount == 0) threadCount = default_concurrency();
+ this->reset(new Theron::Framework(Theron::Framework::Parameters(threadCount, 0)));
}
ThreadPool::ThreadPool(const unsigned long threadCount, const unsigned long nodeMask)