summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-08-29 20:35:36 +0200
committerRobin Gareus <robin@gareus.org>2017-08-29 20:35:36 +0200
commit467c801ce80b69abdb7efb4c23120532bed3fc96 (patch)
treee0ed5e4592819392a5f37d6a8c44003dd96daf0f /libs/pbd
parentdf659e91f1ad8b5d71838abc130dce8eacdf7cc1 (diff)
Abstract definition of rt-scheduler policy
pthread-w32 does not support pthread_setschedparam() with SCHED_FIFO and bails out. While pthread_create() simply ignores the policy and sets the priority regadless. This only affects ctrl-surface event-loops & AutomationWatch on Windows.
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/pbd/base_ui.h3
-rw-r--r--libs/pbd/pbd/pthread_utils.h13
2 files changed, 15 insertions, 1 deletions
diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h
index b8569718ae..4d490fea5c 100644
--- a/libs/pbd/pbd/base_ui.h
+++ b/libs/pbd/pbd/base_ui.h
@@ -32,6 +32,7 @@
#include "pbd/libpbd_visibility.h"
#include "pbd/crossthread.h"
#include "pbd/event_loop.h"
+#include "pbd/pthread_utils.h"
/** A BaseUI is an abstraction designed to be used with any "user
* interface" (not necessarily graphical) that needs to wait on
@@ -91,7 +92,7 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
virtual void thread_init () {};
- int set_thread_priority (const int policy = SCHED_FIFO, int priority = 0) const;
+ int set_thread_priority (const int policy = PBD_SCHED_FIFO, int priority = 0) const;
/** Called when there input ready on the request_channel
*/
diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h
index 2ef442caa5..a1660eb073 100644
--- a/libs/pbd/pbd/pthread_utils.h
+++ b/libs/pbd/pbd/pthread_utils.h
@@ -67,4 +67,17 @@ namespace PBD {
LIBPBD_API extern PBD::Signal3<void,pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize;
}
+/* pthread-w32 does not support realtime scheduling
+ * (well, windows, doesn't..) and only supports SetThreadPriority()
+ *
+ * pthread_setschedparam() returns ENOTSUP if the policy is not SCHED_OTHER.
+ *
+ * however, pthread_create() with attributes, ignores the policy and
+ * only sets the priority (when PTHREAD_EXPLICIT_SCHED is used).
+ */
+#ifdef PLATFORM_WINDOWS
+#define PBD_SCHED_FIFO SCHED_OTHER
+#else
+#define PBD_SCHED_FIFO SCHED_FIFO
+#endif
#endif /* __pbd_pthread_utils__ */