priority_win.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_THREADS_PRIORITY_WIN_HPP_
13 #define ECL_THREADS_PRIORITY_WIN_HPP_
14 
15 /*****************************************************************************
16 ** Platform Check
17 *****************************************************************************/
18 
19 #include <ecl/config/ecl.hpp>
20 #if defined(ECL_IS_WIN32)
21 
22 /*****************************************************************************
23 ** Includes
24 *****************************************************************************/
25 
26 #include <windows.h>
27 #include <string>
28 #include <sstream>
29 #include <errno.h>
30 #include <ecl/config/ecl.hpp>
33 #include "priority_common.hpp"
34 #include "macros.hpp"
35 
36 /*****************************************************************************
37 ** Namespaces
38 *****************************************************************************/
39 
40 namespace ecl {
41 
65 bool ecl_threads_PUBLIC set_priority(Priority priority_level) ecl_debug_throw_decl(StandardException);
72 Priority ecl_threads_PUBLIC get_priority() ecl_debug_throw_decl(StandardException);
73 
79 std::string ecl_threads_PUBLIC print_priority_diagnostics() ecl_debug_throw_decl(StandardException);
80 
81 /*****************************************************************************
82 ** Namespace
83 *****************************************************************************/
84 
85 namespace threads {
86 
102 bool ECL_LOCAL set_real_time_priority(int policy,int priority_level) ecl_debug_throw_decl(StandardException);
103 
104 } // namespace threads
105 } // namespace ecl
106 
107 /*****************************************************************************
108 ** Interface [Exceptions]
109 *****************************************************************************/
110 
111 #if defined(ECL_HAS_EXCEPTIONS)
112 namespace ecl {
113 namespace threads {
114 
115 /*****************************************************************************
116 ** Interface [Priority Exceptions]
117 *****************************************************************************/
130 inline StandardException ECL_LOCAL throwPriorityException(const char* loc ) {
131  int error_result = errno;
132  switch (error_result) {
133  case ( EINVAL ) : return StandardException(loc, ecl::InvalidInputError, "The specified param structure or priority group was invalid.");
134  case ( ESRCH ) : return StandardException(loc, ecl::InvalidInputError, "The process specified could not be found.");
135  case ( EPERM ) : return StandardException(loc, ecl::PermissionsError, "The caller does not have the appropriate privileges for realtime scheduling (http://snorriheim.dnsdojo.com/doku/doku.php/en:linux:admin:priorities).");
136  case ( EACCES ) : return StandardException(loc, ecl::PermissionsError, "The caller does not have the appropriate privileges for elevating the process priority by reducing the niceness value (http://snorriheim.dnsdojo.com/doku/doku.php/en:linux:admin:priorities).");
137  default :
138  {
139  std::ostringstream ostream;
140  ostream << "Unknown posix error " << error_result << ": " << strerror(error_result) << ".";
141  return StandardException(loc, UnknownError, ostream.str());
142  }
143  }
144 }
145 
146 
147 }; // namespace threads
148 } // namespace ecl
149 #endif /* ECL_HAS_EXCEPTIONS */
150 #endif /* ECL_IS_WIN32 */
151 #endif /* ECL_THREADS_PRIORITY_WIN_HPP_ */
#define ecl_threads_PUBLIC
Definition: macros.hpp:37
Embedded control libraries.
Common types for priority scheduling.
PermissionsError
UnknownError
InvalidInputError
#define ecl_debug_throw_decl(exception)
#define ECL_LOCAL
Priority
Shared abstraction of the scheduling priorities.


ecl_threads
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:44