Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)

endif(CMAKE_COMPILER_IS_GNUCXX)

#enable c++11 extensions for OSX
if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wc++11-extensions")
endif(APPLE)

#common headers used by client and server
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)

Expand Down
11 changes: 11 additions & 0 deletions server/ThreadPrioUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include <cstring> //memset, strerror
#include <sched.h>

#ifdef __APPLE__
#include <sys/errno.h>
#include <thread>
#endif

std::string setThreadPrio(const double prio)
{
//no negative priorities supported on this OS
Expand All @@ -21,7 +26,13 @@ std::string setThreadPrio(const double prio)
struct sched_param param;
std::memset(&param, 0, sizeof(param));
param.sched_priority = minPrio + int(prio * (maxPrio-minPrio));

#ifdef __APPLE__
pthread_t tID = pthread_self(); // ID of this thread
if (pthread_setschedparam(tID, policy, &param) != 0) return strerror(errno);
#else
if (sched_setscheduler(0, policy, &param) != 0) return strerror(errno);
#endif

return "";
}