Program Listing for File priority_win.hpp
↰ Return to documentation for file (include/ecl/threads/priority_win.hpp
)
/*****************************************************************************
** Ifdefs
*****************************************************************************/
#ifndef ECL_THREADS_PRIORITY_WIN_HPP_
#define ECL_THREADS_PRIORITY_WIN_HPP_
/*****************************************************************************
** Platform Check
*****************************************************************************/
#include <ecl/config/ecl.hpp>
#if defined(ECL_IS_WIN32)
/*****************************************************************************
** Includes
*****************************************************************************/
#include <windows.h>
#include <string>
#include <sstream>
#include <errno.h>
#include <ecl/config/ecl.hpp>
#include <ecl/exceptions/macros.hpp>
#include <ecl/exceptions/standard_exception.hpp>
#include "priority_common.hpp"
#include "macros.hpp"
/*****************************************************************************
** Namespaces
*****************************************************************************/
namespace ecl {
bool ecl_threads_PUBLIC set_priority(Priority priority_level);
Priority ecl_threads_PUBLIC get_priority();
std::string ecl_threads_PUBLIC print_priority_diagnostics();
/*****************************************************************************
** Namespace
*****************************************************************************/
namespace threads {
bool ECL_LOCAL set_real_time_priority(int policy,int priority_level);
} // namespace threads
} // namespace ecl
/*****************************************************************************
** Interface [Exceptions]
*****************************************************************************/
#if defined(ECL_HAS_EXCEPTIONS)
namespace ecl {
namespace threads {
/*****************************************************************************
** Interface [Priority Exceptions]
*****************************************************************************/
inline StandardException ECL_LOCAL throwPriorityException(const char* loc ) {
int error_result = errno;
switch (error_result) {
case ( EINVAL ) : return StandardException(loc, ecl::InvalidInputError, "The specified param structure or priority group was invalid.");
case ( ESRCH ) : return StandardException(loc, ecl::InvalidInputError, "The process specified could not be found.");
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).");
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).");
default :
{
std::ostringstream ostream;
ostream << "Unknown posix error " << error_result << ": " << strerror(error_result) << ".";
return StandardException(loc, UnknownError, ostream.str());
}
}
}
}; // namespace threads
} // namespace ecl
#endif /* ECL_HAS_EXCEPTIONS */
#endif /* ECL_IS_WIN32 */
#endif /* ECL_THREADS_PRIORITY_WIN_HPP_ */