Abstract definition of rt-scheduler policy
[ardour.git] / libs / pbd / pbd / base_ui.h
index ee2bbf5ee9b0f4edf5b2084fe6720209da2b649a..4d490fea5c401f390442a06014d5d7c5fecce25b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000-2009 Paul Davis 
+    Copyright (C) 2000-2009 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 #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
  * events/requests and dispatch/process them as they arrive.
  *
  * This implementation starts up a thread that runs a Glib main loop
- * to wait on events/requests etc. 
+ * to wait on events/requests etc.
  */
 
 
@@ -54,15 +55,13 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
         Glib::Threads::Thread* event_loop_thread() const { return run_loop_thread; }
         bool caller_is_self () const { return Glib::Threads::Thread::self() == run_loop_thread; }
 
-       std::string name() const { return _name; }
-
        bool ok() const { return _ok; }
-       
+
        static RequestType new_request_type();
        static RequestType CallSlot;
        static RequestType Quit;
 
-       /** start up a thread to run the main loop 
+       /** start up a thread to run the main loop
         */
        void run ();
 
@@ -72,16 +71,16 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
        void quit ();
 
   protected:
-       CrossThreadChannel request_channel;
-       bool _ok; 
+       bool _ok;
 
        Glib::RefPtr<Glib::MainLoop> _main_loop;
-        Glib::Threads::Thread*       run_loop_thread;
+       Glib::RefPtr<Glib::MainContext> m_context;
+       Glib::Threads::Thread*       run_loop_thread;
        Glib::Threads::Mutex        _run_lock;
-        Glib::Threads::Cond         _running;
+       Glib::Threads::Cond         _running;
 
        /* this signals _running from within the event loop,
-          from an idle callback 
+          from an idle callback
        */
 
        bool signal_running ();
@@ -93,10 +92,15 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
 
        virtual void thread_init () {};
 
+       int set_thread_priority (const int policy = PBD_SCHED_FIFO, int priority = 0) const;
+
        /** Called when there input ready on the request_channel
         */
        bool request_handler (Glib::IOCondition);
 
+       void signal_new_request ();
+       void attach_request_source ();
+
        /** Derived UI objects must implement this method,
         * which will be called whenever there are requests
         * to be dealt with.
@@ -104,9 +108,10 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
        virtual void handle_ui_requests () = 0;
 
   private:
-       std::string _name; 
        BaseUI* base_ui_instance;
-       
+
+       CrossThreadChannel request_channel;
+
        static uint64_t rt_bit;
 
        int setup_request_pipe ();