12 #include <ecl/config/ecl.hpp> 13 #if defined(ECL_IS_WIN32) 21 #include "../../include/ecl/threads/priority_win.hpp" 33 using std::ostringstream;
42 return threads::set_real_time_priority(0, priority_level);
46 HANDLE hThread = GetCurrentThread();
53 switch (priority_level) {
55 bResult = SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST);
58 bResult = SetThreadPriority(hThread, THREAD_PRIORITY_ABOVE_NORMAL);
61 bResult = SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL);
64 bResult = SetThreadPriority(hThread, THREAD_PRIORITY_BELOW_NORMAL);
67 bResult = SetThreadPriority(hThread, THREAD_PRIORITY_IDLE);
81 Priority get_priority() ecl_debug_throw_decl(StandardException)
83 HANDLE hThread = GetCurrentThread();
90 DWORD dwPriority = GetThreadPriority(hThread);
93 case THREAD_PRIORITY_TIME_CRITICAL:
95 case THREAD_PRIORITY_HIGHEST:
97 case THREAD_PRIORITY_ABOVE_NORMAL:
99 case THREAD_PRIORITY_NORMAL:
101 case THREAD_PRIORITY_BELOW_NORMAL:
103 case THREAD_PRIORITY_IDLE:
116 std::string print_priority_diagnostics() ecl_debug_throw_decl(StandardException) {
118 ostringstream ostream;
121 ostream <<
"***********************************************************\n";
122 ostream <<
"* Priority Statistics\n";
123 ostream <<
"***********************************************************\n";
125 switch ( get_priority() ) {
127 ostream <<
"Priority...................................Background\n";
131 ostream <<
"Priority...................................Low\n";
135 ostream <<
"Priority...................................Normal\n";
139 ostream <<
"Priority...................................High\n";
143 ostream <<
"Priority...................................Critical\n";
147 ostream <<
"Priority...................................RealTime4\n";
151 ostream <<
"Priority...................................RealTime3\n";
155 ostream <<
"Priority...................................RealTime2\n";
159 ostream <<
"Priority...................................RealTime1\n";
163 ostream <<
"Priority...................................Default (Inherited)\n";
167 ostream <<
"Priority...................................Unknown\n";
171 return ostream.str();
181 bool set_real_time_priority(
int policy,
int priority_level)
ecl_debug_throw_decl(StandardException) {
184 HANDLE hThread = GetCurrentThread();
191 BOOL bResult = FALSE;
194 bResult = SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
197 return bResult != FALSE;
Embedded control libraries.
#define ecl_debug_throw_decl(exception)
#define ecl_debug_throw(exception)
Priority
Shared abstraction of the scheduling priorities.