47#if LASS_PLATFORM_TYPE == LASS_PLATFORM_TYPE_WIN32
48# define LASS_UTIL_PROCESS_HAVE_WIN32
49#elif LASS_HAVE_SYS_RESOURCE_H
50# define LASS_UTIL_PROCESS_HAVE_SYS_RESOURCE
52# error lass/util/process.h is not supported on this platform
55#if defined(LASS_UTIL_PROCESS_HAVE_WIN32)
57# define WIN32_LEAN_AND_MEAN
59#elif defined(LASS_UTIL_PROCESS_HAVE_SYS_RESOURCE)
60# include <sys/resource.h>
61# if LASS_HAVE_LIMITS_H
74LASS_EXECUTE_BEFORE_MAIN_EX(lassImpl_processPriorityDictionary,
86 LASS_ASSERT(iPriority >= 0 && iPriority < numberOfProcessPriorities);
88#if defined(LASS_UTIL_PROCESS_HAVE_WIN32)
89 static const int winPriorities[numberOfProcessPriorities] =
92 BELOW_NORMAL_PRIORITY_CLASS,
93 NORMAL_PRIORITY_CLASS,
94 ABOVE_NORMAL_PRIORITY_CLASS,
97 const int priority = winPriorities[iPriority];
98 LASS_ENFORCE_WINAPI(SetPriorityClass(GetCurrentProcess(), priority))
99 (
"Failed to set process priority");
101#elif defined(LASS_UTIL_PROCESS_HAVE_SYS_RESOURCE)
102 static const int niceValues[numberOfProcessPriorities] =
110 const int niceValue = niceValues[iPriority];
111 LASS_ENFORCE_CLIB(setpriority(PRIO_PROCESS, 0, niceValue));
114# error setProcessPriority is not supported on this platform
129 LASS_THROW(
"'" << iPriority <<
"' is an invalid priority setting. "
void add(const TKey &iKey, const TValue &iValue)
add a key and value to dictionary as new entry.
type of all exceptions in lass
ProcessPriority
different process priority levels
TProcessPriorityDictionary & processPriorityDictionary()
singleton with dictionary that can translate strings to ProcessPriority.
void setProcessPriority(const std::string &iPriority)
set process priority by string
general utility, debug facilities, ...
Library for Assembled Shared Sources.