diff options
Diffstat (limited to 'raul/Thread.hpp')
-rw-r--r-- | raul/Thread.hpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/raul/Thread.hpp b/raul/Thread.hpp index 9720007..11cd0fb 100644 --- a/raul/Thread.hpp +++ b/raul/Thread.hpp @@ -68,10 +68,14 @@ public: * @return True on success. */ virtual bool set_scheduling(bool realtime, unsigned priority) { - sched_param sp; - sp.sched_priority = priority; - const int policy = realtime ? SCHED_FIFO : SCHED_OTHER; - return !pthread_setschedparam(_pthread, policy, &sp); + if (_thread_exists) { + sched_param sp; + sp.sched_priority = priority; + const int policy = realtime ? SCHED_FIFO : SCHED_OTHER; + return !pthread_setschedparam(_pthread, policy, &sp); + } else { + return false; + } } protected: |