summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/block_actor.cpp2
-rw-r--r--lib/thread_pool.cpp37
2 files changed, 37 insertions, 2 deletions
diff --git a/lib/block_actor.cpp b/lib/block_actor.cpp
index 3ce7742..464167f 100644
--- a/lib/block_actor.cpp
+++ b/lib/block_actor.cpp
@@ -3,7 +3,7 @@
#include <gras/thread_pool.hpp>
#include <gras_impl/block_actor.hpp>
#include <Theron/Framework.h>
-#include <stdexcept>
+#include <iostream>
using namespace gras;
diff --git a/lib/thread_pool.cpp b/lib/thread_pool.cpp
index cd5c320..05c5bda 100644
--- a/lib/thread_pool.cpp
+++ b/lib/thread_pool.cpp
@@ -1,10 +1,12 @@
// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
#include <gras/thread_pool.hpp>
-#include <boost/thread/thread.hpp>
+#include <boost/thread.hpp> //mutex, thread, hardware_concurrency
#include <Theron/EndPoint.h>
#include <Theron/Framework.h>
+#include <Theron/Detail/Threading/Utils.h> //prio test
#include <stdexcept>
+#include <iostream>
using namespace gras;
@@ -55,3 +57,36 @@ ThreadPool::ThreadPool(const ThreadPoolConfig &config)
this->reset(new Theron::Framework(Theron::Framework::Parameters(params)));
}
+
+static void test_thread_priority_thread(
+ const float thread_priority,
+ bool &result, bool &called,
+ boost::mutex &mutex
+)
+{
+ std::cout << "Created thread to test priority " << thread_priority << std::endl;
+ result = Theron::Detail::Utils::SetThreadRelativePriority(thread_priority);
+ called = true;
+ mutex.unlock();
+}
+
+bool ThreadPool::test_thread_priority(const float thread_priority)
+{
+ boost::mutex mutex;
+ boost::thread_group thread_group;
+ bool result = false;
+ bool called = false;
+ mutex.lock();
+ thread_group.create_thread(boost::bind(
+ &test_thread_priority_thread,
+ thread_priority,
+ boost::ref(result),
+ boost::ref(called),
+ boost::ref(mutex)
+ ));
+ mutex.lock();
+ mutex.unlock();
+ thread_group.join_all();
+ if (not called) throw std::runtime_error("test_thread_priority_thread never executed");
+ return result;
+}