summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-05-14 05:45:15 +0000
committerDavid Robillard <d@drobilla.net>2012-05-14 05:45:15 +0000
commitff4c3ff14e76e5b06f1b4c44f03f900e1bd4ac50 (patch)
treea66a97f7f842caa51ee6891d2f5037b6707c6784 /src
parent79deafe642561936ebb3bbcf585f2c6f26b456d3 (diff)
downloadraul-ff4c3ff14e76e5b06f1b4c44f03f900e1bd4ac50.tar.gz
raul-ff4c3ff14e76e5b06f1b4c44f03f900e1bd4ac50.tar.bz2
raul-ff4c3ff14e76e5b06f1b4c44f03f900e1bd4ac50.zip
Clean up Thread interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4411 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/Thread.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/Thread.cpp b/src/Thread.cpp
index 4a3e7bf..34d7b65 100644
--- a/src/Thread.cpp
+++ b/src/Thread.cpp
@@ -36,21 +36,21 @@ struct ThreadImpl {
static ThreadVar<Thread*> self(NULL);
Thread::Thread(const std::string& name)
- : _exit_flag(false)
- , _impl(new ThreadImpl())
+ : _impl(new ThreadImpl())
, _name(name)
, _thread_exists(false)
, _own_thread(true)
+ , _exit_flag(false)
{
}
/** Must be called from thread */
Thread::Thread(pthread_t thread, const std::string& name)
- : _exit_flag(false)
- , _impl(new ThreadImpl())
+ : _impl(new ThreadImpl())
, _name(name)
, _thread_exists(true)
, _own_thread(false)
+ , _exit_flag(false)
{
_impl->pthread = thread;
}
@@ -81,7 +81,6 @@ Thread::_static_run(void* thread)
return NULL;
}
-/** Launch and start the thread. */
void
Thread::start()
{
@@ -97,7 +96,6 @@ Thread::start()
}
}
-/** Stop and terminate the thread. */
void
Thread::stop()
{
@@ -119,23 +117,19 @@ Thread::join()
}
void
-Thread::set_scheduling(int policy, unsigned int priority)
+Thread::set_scheduling(bool realtime, unsigned priority)
{
sched_param sp;
sp.sched_priority = priority;
- int result = pthread_setschedparam(_impl->pthread, policy, &sp);
+ const int policy = realtime ? SCHED_FIFO : SCHED_OTHER;
+ const int result = pthread_setschedparam(_impl->pthread, policy, &sp);
if (!result) {
- LOG(info) << "Set scheduling policy to ";
- switch (policy) {
- case SCHED_FIFO: info << "SCHED_FIFO"; break;
- case SCHED_RR: info << "SCHED_RR"; break;
- case SCHED_OTHER: info << "SCHED_OTHER"; break;
- default: info << "UNKNOWN"; break;
- }
- info << ", priority " << sp.sched_priority << endl;
+ LOG(info) << (fmt("Set scheduling policy to %1% priority %2%\n")
+ % (realtime ? "realtime" : "normal")
+ % sp.sched_priority);
} else {
- LOG(info) << "Unable to set scheduling policy ("
- << strerror(result) << ")" << endl;
+ LOG(info) << (fmt("Unable to set scheduling policy (%1%)\n")
+ % strerror(result));
}
}