diff options
author | Benoit Foucher <benoit@zeroc.com> | 2005-09-05 15:28:17 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2005-09-05 15:28:17 +0000 |
commit | c2dd2364ec91fdb68318cd05813e1aa6a744fff8 (patch) | |
tree | 031be38ba44f9ef44b72f1b3649bfc5637173e19 /cpp/src | |
parent | Added support for adaptive load balancing. (diff) | |
download | ice-c2dd2364ec91fdb68318cd05813e1aa6a744fff8.tar.bz2 ice-c2dd2364ec91fdb68318cd05813e1aa6a744fff8.tar.xz ice-c2dd2364ec91fdb68318cd05813e1aa6a744fff8.zip |
Fix
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/NodeI.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp index 60a00839d25..f8a9b0cb488 100644 --- a/cpp/src/IceGrid/NodeI.cpp +++ b/cpp/src/IceGrid/NodeI.cpp @@ -23,6 +23,8 @@ # include <direct.h> // For _getcwd #endif +#include <sys/sysctl.h> + using namespace std; using namespace IcePatch2; using namespace IceGrid; @@ -217,7 +219,20 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter, _observer = RegistryPrx::uncheckedCast(registry)->getNodeObserver(); #ifndef _WIN32 +#if defined(__linux) _nproc = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN)); +#elif defined(__APPLE__) + static int ncpu[2] = { CTL_HW, HW_NCPU }; + size_t sz = sizeof(_nproc); + if(sysctl(ncpu, sizeof(ncpu), &_nproc, &sz, 0, 0) < 0) + { + Ice::SyscallException ex(__FILE__, __LINE__); + ex.error = getSystemErrno(); + throw ex; + } +#else + _nproc = 1; +#endif assert(_nproc > 0); #endif } |