27 #ifndef RL_UTIL_PROCESS_H
28 #define RL_UTIL_PROCESS_H
39 #include <system_error>
45 namespace this_process
50 return REALTIME_PRIORITY_CLASS;
52 return ::sched_get_priority_max(SCHED_FIFO);
59 return IDLE_PRIORITY_CLASS;
61 return ::sched_get_priority_min(SCHED_FIFO);
67 #if !defined(WIN32) && !defined(__APPLE__)
68 if (-1 == ::mlockall(MCL_CURRENT | MCL_FUTURE))
70 throw ::std::system_error(::std::error_code(errno, ::std::generic_category()));
72 #endif // !WIN32 && !__APPLE__
79 char* buffer =
new char[size];
81 for (::std::size_t i = 0; i < size; i += ::sysconf(_SC_PAGESIZE))
92 #if !defined(WIN32) && !defined(__APPLE__)
93 if (-1 == ::munlockall())
95 throw ::std::system_error(::std::error_code(errno, ::std::generic_category()));
97 #endif // !WIN32 && !__APPLE__
103 if (!::SetPriorityClass(::GetCurrentProcess(), priority))
105 throw ::std::system_error(::std::error_code(::GetLastError(), ::std::generic_category()));
109 param.sched_priority = priority;
112 #warning "rl/util/process.h: set_priority not implemented for Mac OS"
114 ::std::cerr <<
"set_priority not implemented for Mac OS" << ::std::endl;
116 if (-1 == ::sched_setscheduler(::getpid(), SCHED_FIFO, ¶m))
118 throw ::std::system_error(::std::error_code(errno, ::std::generic_category()));
127 #endif // RL_UTIL_PROCESS_H