]> git.sesse.net Git - casparcg/commitdiff
2.1.0: executor: Refactored. Removed thread priorities to simplify API.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 4 Feb 2012 17:18:48 +0000 (17:18 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 4 Feb 2012 17:18:48 +0000 (17:18 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.1.0@2233 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

casparcg.sln
common/concurrency/executor.h
common/diagnostics/graph.cpp
common/prec_timer.h

index 07e2669498156e7edd3fc0254df40e7a47c96cec..fdb5cfc79f79ebf49e7bb5496d83af7d5c84e0a7 100644 (file)
@@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat
        ProjectSection(SolutionItems) = preProject\r
                COPYING.txt = COPYING.txt\r
                README.txt = README.txt\r
+               TODO.txt = TODO.txt\r
        EndProjectSection\r
 EndProject\r
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modules", "modules", "{C54DA43E-4878-45DB-B76D-35970553672C}"\r
index 8d1ed1a1b846360fc80889346173cf71b9fa2efa..14d9c1d1f2982f619de1ee0a25b0b2137e638c62 100644 (file)
@@ -22,9 +22,8 @@
 #pragma once\r
 \r
 #include "../except.h"\r
-#include "../log.h"\r
 #include "../enum_class.h"\r
-#include "../os/windows/windows.h"\r
+#include "../log.h"\r
 \r
 #include <tbb/atomic.h>\r
 #include <tbb/concurrent_queue.h>\r
@@ -64,26 +63,13 @@ struct task_priority_def
 };\r
 typedef enum_class<task_priority_def> task_priority;\r
 \r
-struct thread_priority_def\r
-{\r
-       enum type\r
-       {\r
-               high_priority_class,\r
-               above_normal_priority_class,\r
-               normal_priority_class,\r
-               below_normal_priority_class\r
-       };\r
-};\r
-typedef enum_class<thread_priority_def> thread_priority;\r
-\r
 class executor\r
 {\r
        executor(const executor&);\r
        executor& operator=(const executor&);\r
-\r
-       const std::string name_;\r
-       boost::thread thread_;\r
-       tbb::atomic<bool> is_running_;\r
+       \r
+       tbb::atomic<bool>       is_running_;\r
+       boost::thread           thread_;\r
        \r
        typedef tbb::concurrent_bounded_queue<std::function<void()>> function_queue;\r
        function_queue execution_queue_[task_priority::priority_count];\r
@@ -108,10 +94,10 @@ class executor
                return std::move(task);\r
        }\r
 \r
-public:\r
-               \r
-       explicit executor(const std::wstring& name) : name_(u8(name)) // noexcept\r
+public:                \r
+       executor(const std::wstring& name) // noexcept\r
        {\r
+               name; // TODO: Use to set thread name.\r
                is_running_ = true;\r
                thread_ = boost::thread([this]{run();});\r
        }\r
@@ -126,21 +112,6 @@ public:
        {\r
                execution_queue_[task_priority::normal_priority].set_capacity(capacity);\r
        }\r
-\r
-       void set_priority_class(thread_priority p)\r
-       {\r
-               begin_invoke([=]\r
-               {\r
-                       if(p == thread_priority::high_priority_class)\r
-                               SetThreadPriority(GetCurrentThread(), HIGH_PRIORITY_CLASS);\r
-                       else if(p == thread_priority::above_normal_priority_class)\r
-                               SetThreadPriority(GetCurrentThread(), ABOVE_NORMAL_PRIORITY_CLASS);\r
-                       else if(p == thread_priority::normal_priority_class)\r
-                               SetThreadPriority(GetCurrentThread(), NORMAL_PRIORITY_CLASS);\r
-                       else if(p == thread_priority::below_normal_priority_class)\r
-                               SetThreadPriority(GetCurrentThread(), BELOW_NORMAL_PRIORITY_CLASS);\r
-               });\r
-       }\r
        \r
        void clear()\r
        {               \r
@@ -240,7 +211,6 @@ private:
        void run() // noexcept\r
        {\r
                win32_exception::install_handler();             \r
-               //detail::SetThreadName(GetCurrentThreadId(), name_.c_str());\r
                while(is_running_)\r
                {\r
                        try\r
index c84e548f848ae2943a99fbceab379e230d586ae6..1de4bb95a2d37c828df0055949d11a3fe2159c84 100644 (file)
@@ -103,7 +103,10 @@ public:
 private:\r
        context() : executor_(L"diagnostics")\r
        {\r
-               executor_.set_priority_class(thread_priority::below_normal_priority_class);\r
+               executor_.begin_invoke([=]\r
+               {                       \r
+                       SetThreadPriority(GetCurrentThread(), BELOW_NORMAL_PRIORITY_CLASS);\r
+               });\r
        }\r
 \r
        void do_show(bool value)\r
index 82bed017d9916913850f6e38aff688090666bff3..c3f7ffe85297d6fed1479ce11b2455caa6581dfa 100644 (file)
@@ -33,7 +33,7 @@ public:
        void tick(double interval);\r
 \r
 private:       \r
-       DWORD time_;\r
+       unsigned long time_;\r
 };\r
 \r
 \r