From 4c1fe9ef029363fc42bdefa03b38356f533e8422 Mon Sep 17 00:00:00 2001 From: ale_bychuk Date: Wed, 11 Mar 2015 23:39:21 +0300 Subject: [PATCH 1/4] add thread affinity policy to threadpool there are OS_DEFAULT, UNIFORM_DISTRIBUTION and CUSTOM With custom policy we can run thread on specified cpu --- Foundation/include/Poco/ThreadPool.h | 36 +++++--- Foundation/src/ThreadPool.cpp | 93 ++++++++++++++++----- Foundation/testsuite/src/ThreadPoolTest.cpp | 40 ++++++--- Foundation/testsuite/src/ThreadPoolTest.h | 5 +- 4 files changed, 131 insertions(+), 43 deletions(-) diff --git a/Foundation/include/Poco/ThreadPool.h b/Foundation/include/Poco/ThreadPool.h index 0058efa24..2384c88ac 100644 --- a/Foundation/include/Poco/ThreadPool.h +++ b/Foundation/include/Poco/ThreadPool.h @@ -32,7 +32,6 @@ namespace Poco { class Runnable; class PooledThread; - class Foundation_API ThreadPool /// A thread pool always keeps a number of threads running, ready /// to accept work. @@ -49,28 +48,39 @@ class Foundation_API ThreadPool /// from the pool. { public: + typedef enum _ThreadAffinityPolicy + { + OS_DEFAULT = 0, + UNIFORM_DISTRIBUTION, + CUSTOM + } ThreadAffinityPolicy; + ThreadPool(int minCapacity = 2, int maxCapacity = 16, int idleTime = 60, - int stackSize = POCO_THREAD_STACK_SIZE); + int stackSize = POCO_THREAD_STACK_SIZE, + ThreadAffinityPolicy affinityPolicy = OS_DEFAULT); /// Creates a thread pool with minCapacity threads. /// If required, up to maxCapacity threads are created /// a NoThreadAvailableException exception is thrown. /// If a thread is running idle for more than idleTime seconds, /// and more than minCapacity threads are running, the thread /// is killed. Threads are created with given stack size. + /// Threads are created with given affinity Policy ThreadPool(const std::string& name, int minCapacity = 2, int maxCapacity = 16, int idleTime = 60, - int stackSize = POCO_THREAD_STACK_SIZE); + int stackSize = POCO_THREAD_STACK_SIZE, + ThreadAffinityPolicy affinityPolicy = OS_DEFAULT); /// Creates a thread pool with the given name and minCapacity threads. /// If required, up to maxCapacity threads are created /// a NoThreadAvailableException exception is thrown. /// If a thread is running idle for more than idleTime seconds, /// and more than minCapacity threads are running, the thread /// is killed. Threads are created with given stack size. + /// Threads are created with given affinity Policy ~ThreadPool(); /// Currently running threads will remain active @@ -99,24 +109,24 @@ public: int available() const; /// Returns the number available threads. - void start(Runnable& target); - /// Obtains a thread and starts the target. + void start(Runnable& target, int cpu = -1); + /// Obtains a thread and starts the target on specified cpu. /// Throws a NoThreadAvailableException if no more /// threads are available. - void start(Runnable& target, const std::string& name); - /// Obtains a thread and starts the target. + void start(Runnable& target, const std::string& name, int cpu = -1); + /// Obtains a thread and starts the target on specified cpu. /// Assigns the given name to the thread. /// Throws a NoThreadAvailableException if no more /// threads are available. - void startWithPriority(Thread::Priority priority, Runnable& target); - /// Obtains a thread, adjusts the thread's priority, and starts the target. + void startWithPriority(Thread::Priority priority, Runnable& target, int cpu = -1); + /// Obtains a thread, adjusts the thread's priority, and starts the target on specified cpu. /// Throws a NoThreadAvailableException if no more /// threads are available. - void startWithPriority(Thread::Priority priority, Runnable& target, const std::string& name); - /// Obtains a thread, adjusts the thread's priority, and starts the target. + void startWithPriority(Thread::Priority priority, Runnable& target, const std::string& name, int cpu = -1); + /// Obtains a thread, adjusts the thread's priority, and starts the target on specified cpu. /// Assigns the given name to the thread. /// Throws a NoThreadAvailableException if no more /// threads are available. @@ -168,7 +178,7 @@ protected: private: ThreadPool(const ThreadPool& pool); ThreadPool& operator = (const ThreadPool& pool); - + int getCorrectCpu(int cpu); typedef std::vector ThreadVec; std::string _name; @@ -180,6 +190,8 @@ private: int _stackSize; ThreadVec _threads; mutable FastMutex _mutex; + ThreadAffinityPolicy _affinityPolicy; + AtomicCounter _lastCpu; }; diff --git a/Foundation/src/ThreadPool.cpp b/Foundation/src/ThreadPool.cpp index e8df55c9d..61ab36299 100644 --- a/Foundation/src/ThreadPool.cpp +++ b/Foundation/src/ThreadPool.cpp @@ -36,9 +36,9 @@ public: PooledThread(const std::string& name, int stackSize = POCO_THREAD_STACK_SIZE); ~PooledThread(); - void start(); - void start(Thread::Priority priority, Runnable& target); - void start(Thread::Priority priority, Runnable& target, const std::string& name); + void start(int cpu = -1); + void start(Thread::Priority priority, Runnable& target, int cpu = -1); + void start(Thread::Priority priority, Runnable& target, const std::string& name, int cpu = -1); bool idle(); int idleTime(); void join(); @@ -85,14 +85,17 @@ PooledThread::~PooledThread() } -void PooledThread::start() +void PooledThread::start(int cpu) { _thread.start(*this); _started.wait(); + if (cpu >= 0) { + _thread.setAffinity(static_cast(cpu)); + } } -void PooledThread::start(Thread::Priority priority, Runnable& target) +void PooledThread::start(Thread::Priority priority, Runnable& target, int cpu) { FastMutex::ScopedLock lock(_mutex); @@ -101,10 +104,13 @@ void PooledThread::start(Thread::Priority priority, Runnable& target) _pTarget = ⌖ _thread.setPriority(priority); _targetReady.set(); + if (cpu >= 0) { + _thread.setAffinity(static_cast(cpu)); + } } -void PooledThread::start(Thread::Priority priority, Runnable& target, const std::string& name) +void PooledThread::start(Thread::Priority priority, Runnable& target, const std::string& name, int cpu) { FastMutex::ScopedLock lock(_mutex); @@ -126,6 +132,9 @@ void PooledThread::start(Thread::Priority priority, Runnable& target, const std: _pTarget = ⌖ _targetReady.set(); + if (cpu >= 0) { + _thread.setAffinity(static_cast(cpu)); + } } @@ -239,21 +248,31 @@ void PooledThread::run() ThreadPool::ThreadPool(int minCapacity, int maxCapacity, int idleTime, - int stackSize): + int stackSize, + ThreadAffinityPolicy affinityPolicy): _minCapacity(minCapacity), _maxCapacity(maxCapacity), _idleTime(idleTime), _serial(0), _age(0), - _stackSize(stackSize) + _stackSize(stackSize), + _affinityPolicy(affinityPolicy), + _lastCpu(0) { poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0); + int cpu = -1; + int cpuCount = Poco::Environment::processorCount(); + for (int i = 0; i < _minCapacity; i++) { + if (_affinityPolicy == UNIFORM_DISTRIBUTION) { + cpu = _lastCpu.value() % cpuCount; + _lastCpu++; + } PooledThread* pThread = createThread(); _threads.push_back(pThread); - pThread->start(); + pThread->start(cpu); } } @@ -262,22 +281,31 @@ ThreadPool::ThreadPool(const std::string& name, int minCapacity, int maxCapacity, int idleTime, - int stackSize): + int stackSize, + ThreadAffinityPolicy affinityPolicy): _name(name), _minCapacity(minCapacity), _maxCapacity(maxCapacity), _idleTime(idleTime), _serial(0), _age(0), - _stackSize(stackSize) + _stackSize(stackSize), + _affinityPolicy(affinityPolicy), + _lastCpu(0) { poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0); + int cpu = -1; + int cpuCount = Poco::Environment::processorCount(); for (int i = 0; i < _minCapacity; i++) { + if (_affinityPolicy == UNIFORM_DISTRIBUTION) { + cpu = _lastCpu.value() % cpuCount; + _lastCpu++; + } PooledThread* pThread = createThread(); _threads.push_back(pThread); - pThread->start(); + pThread->start(cpu); } } @@ -346,27 +374,52 @@ int ThreadPool::allocated() const } -void ThreadPool::start(Runnable& target) +int ThreadPool::getCorrectCpu(int cpu) { - getThread()->start(Thread::PRIO_NORMAL, target); + switch (static_cast(_affinityPolicy)) { + case UNIFORM_DISTRIBUTION: + { + cpu = _lastCpu.value() % Environment::processorCount(); + _lastCpu++; + } + break; + case OS_DEFAULT: + { + cpu = -1; + } + break; + case CUSTOM: + { + if ((cpu < -1) || (cpu >= Environment::processorCount())) { + throw InvalidArgumentException("cpu argument is invalid"); + } + } + break; + } + return cpu; +} + +void ThreadPool::start(Runnable& target, int cpu) +{ + getThread()->start(Thread::PRIO_NORMAL, target, getCorrectCpu(cpu)); } -void ThreadPool::start(Runnable& target, const std::string& name) +void ThreadPool::start(Runnable& target, const std::string& name, int cpu) { - getThread()->start(Thread::PRIO_NORMAL, target, name); + getThread()->start(Thread::PRIO_NORMAL, target, name, getCorrectCpu(cpu)); } -void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target) +void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target, int cpu) { - getThread()->start(priority, target); + getThread()->start(priority, target, getCorrectCpu(cpu)); } -void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target, const std::string& name) +void ThreadPool::startWithPriority(Thread::Priority priority, Runnable& target, const std::string& name, int cpu) { - getThread()->start(priority, target, name); + getThread()->start(priority, target, name, getCorrectCpu(cpu)); } diff --git a/Foundation/testsuite/src/ThreadPoolTest.cpp b/Foundation/testsuite/src/ThreadPoolTest.cpp index 3083f90f0..65330dab4 100644 --- a/Foundation/testsuite/src/ThreadPoolTest.cpp +++ b/Foundation/testsuite/src/ThreadPoolTest.cpp @@ -35,9 +35,13 @@ ThreadPoolTest::~ThreadPoolTest() } -void ThreadPoolTest::testThreadPool() +void ThreadPoolTest::startThreadPoolTest(int affinityPolicy) { - ThreadPool pool(2, 3, 3); + int cpu = -1; + if (affinityPolicy == static_cast(ThreadPool::CUSTOM)) { + cpu = 0; + } + ThreadPool pool(2, 3, 3, POCO_THREAD_STACK_SIZE, static_cast(affinityPolicy)); pool.setStackSize(1); assert (pool.allocated() == 2); @@ -51,25 +55,25 @@ void ThreadPoolTest::testThreadPool() assert (pool.available() == 4); RunnableAdapter ra(*this, &ThreadPoolTest::count); - pool.start(ra); + pool.start(ra, cpu); assert (pool.allocated() == 2); assert (pool.used() == 1); assert (pool.capacity() == 4); assert (pool.available() == 3); - pool.start(ra); + pool.start(ra, cpu); assert (pool.allocated() == 2); assert (pool.used() == 2); assert (pool.capacity() == 4); assert (pool.available() == 2); - pool.start(ra); + pool.start(ra, cpu); assert (pool.allocated() == 3); assert (pool.used() == 3); assert (pool.capacity() == 4); assert (pool.available() == 1); - pool.start(ra); + pool.start(ra, cpu); assert (pool.allocated() == 4); assert (pool.used() == 4); assert (pool.capacity() == 4); @@ -77,7 +81,7 @@ void ThreadPoolTest::testThreadPool() try { - pool.start(ra); + pool.start(ra, cpu); failmsg("thread pool exhausted - must throw exception"); } catch (Poco::NoThreadAvailableException&) @@ -108,13 +112,13 @@ void ThreadPoolTest::testThreadPool() _count = 0; _event.reset(); - pool.start(ra); + pool.start(ra, cpu); assert (pool.allocated() == 2); assert (pool.used() == 1); assert (pool.capacity() == 4); assert (pool.available() == 3); - pool.start(ra); + pool.start(ra, cpu); assert (pool.allocated() == 2); assert (pool.used() == 2); assert (pool.capacity() == 4); @@ -127,9 +131,23 @@ void ThreadPoolTest::testThreadPool() assert (pool.allocated() == 2); assert (pool.used() == 0); assert (pool.capacity() == 4); - assert (pool.available() == 4); + assert (pool.available() == 4); } +void ThreadPoolTest::testThreadPool() +{ + startThreadPoolTest(Poco::ThreadPool::OS_DEFAULT); +} + +void ThreadPoolTest::testThreadPoolUniformDistribution() +{ + startThreadPoolTest(Poco::ThreadPool::UNIFORM_DISTRIBUTION); +} + +void ThreadPoolTest::testThreadPoolCustomDistribution() +{ + startThreadPoolTest(Poco::ThreadPool::CUSTOM); +} void ThreadPoolTest::setUp() { @@ -160,6 +178,8 @@ CppUnit::Test* ThreadPoolTest::suite() CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ThreadPoolTest"); CppUnit_addTest(pSuite, ThreadPoolTest, testThreadPool); + CppUnit_addTest(pSuite, ThreadPoolTest, testThreadPoolUniformDistribution); + CppUnit_addTest(pSuite, ThreadPoolTest, testThreadPoolCustomDistribution); return pSuite; } diff --git a/Foundation/testsuite/src/ThreadPoolTest.h b/Foundation/testsuite/src/ThreadPoolTest.h index 80e662bd7..1da8babd2 100644 --- a/Foundation/testsuite/src/ThreadPoolTest.h +++ b/Foundation/testsuite/src/ThreadPoolTest.h @@ -29,7 +29,9 @@ public: ~ThreadPoolTest(); void testThreadPool(); - + void testThreadPoolUniformDistribution(); + void testThreadPoolCustomDistribution(); + void setUp(); void tearDown(); @@ -39,6 +41,7 @@ protected: void count(); private: + void startThreadPoolTest(int affinityPolicy); Poco::FastMutex _mutex; Poco::Event _event; int _count; From 9d4d3e41dd1b57e752ffdf4d080e078cafecadf7 Mon Sep 17 00:00:00 2001 From: ale_bychuk Date: Thu, 12 Mar 2015 16:12:33 +0300 Subject: [PATCH 2/4] Add thread affinity support to taskmanager --- Foundation/include/Poco/TaskManager.h | 10 +++++----- Foundation/include/Poco/ThreadPool.h | 17 ++++++++++++++++- Foundation/src/TaskManager.cpp | 9 ++++----- Foundation/src/ThreadPool.cpp | 7 ++++--- Foundation/testsuite/src/TaskManagerTest.cpp | 12 ++++++------ 5 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Foundation/include/Poco/TaskManager.h b/Foundation/include/Poco/TaskManager.h index 077371dcb..08d679e10 100644 --- a/Foundation/include/Poco/TaskManager.h +++ b/Foundation/include/Poco/TaskManager.h @@ -26,6 +26,7 @@ #include "Poco/AutoPtr.h" #include "Poco/NotificationCenter.h" #include "Poco/Timestamp.h" +#include "Poco/ThreadPool.h" #include @@ -33,7 +34,6 @@ namespace Poco { class Notification; -class ThreadPool; class Exception; @@ -52,7 +52,7 @@ public: typedef AutoPtr TaskPtr; typedef std::list TaskList; - TaskManager(); + TaskManager(ThreadPool::ThreadAffinityPolicy affinityPolicy = ThreadPool::OS_DEFAULT); /// Creates the TaskManager, using the /// default ThreadPool. @@ -63,10 +63,10 @@ public: ~TaskManager(); /// Destroys the TaskManager. - void start(Task* pTask); + void start(Task* pTask, int cpu = -1); /// Starts the given task in a thread obtained - /// from the thread pool. - /// + /// from the thread pool, + /// on specified cpu. /// The TaskManager takes ownership of the Task object /// and deletes it when it it finished. diff --git a/Foundation/include/Poco/ThreadPool.h b/Foundation/include/Poco/ThreadPool.h index 2384c88ac..42fe35fa2 100644 --- a/Foundation/include/Poco/ThreadPool.h +++ b/Foundation/include/Poco/ThreadPool.h @@ -100,6 +100,12 @@ public: int getStackSize() const; /// Returns the stack size used to create new threads. + void setAffinityPolicy(ThreadAffinityPolicy affinityPolicy); + /// Sets the thread affinity policy for newly created threads + + ThreadAffinityPolicy getAffinityPolicy(); + /// Returns the thread affinity policy used to create new thread + int used() const; /// Returns the number of currently used threads. @@ -165,7 +171,7 @@ public: /// or an empty string if no name has been /// specified in the constructor. - static ThreadPool& defaultPool(); + static ThreadPool& defaultPool(ThreadAffinityPolicy affinityPolicy = OS_DEFAULT); /// Returns a reference to the default /// thread pool. @@ -209,6 +215,15 @@ inline int ThreadPool::getStackSize() const return _stackSize; } +inline void ThreadPool::setAffinityPolicy(ThreadPool::ThreadAffinityPolicy affinityPolicy) +{ + _affinityPolicy = affinityPolicy; +} + +inline ThreadPool::ThreadAffinityPolicy ThreadPool::getAffinityPolicy() +{ + return _affinityPolicy; +} inline const std::string& ThreadPool::name() const { diff --git a/Foundation/src/TaskManager.cpp b/Foundation/src/TaskManager.cpp index 3fdf011b1..1e2e6bc9a 100644 --- a/Foundation/src/TaskManager.cpp +++ b/Foundation/src/TaskManager.cpp @@ -16,7 +16,6 @@ #include "Poco/TaskManager.h" #include "Poco/TaskNotification.h" -#include "Poco/ThreadPool.h" namespace Poco { @@ -25,8 +24,8 @@ namespace Poco { const int TaskManager::MIN_PROGRESS_NOTIFICATION_INTERVAL = 100000; // 100 milliseconds -TaskManager::TaskManager(): - _threadPool(ThreadPool::defaultPool()) +TaskManager::TaskManager(ThreadPool::ThreadAffinityPolicy affinityPolicy): + _threadPool(ThreadPool::defaultPool(affinityPolicy)) { } @@ -42,7 +41,7 @@ TaskManager::~TaskManager() } -void TaskManager::start(Task* pTask) +void TaskManager::start(Task* pTask, int cpu) { TaskPtr pAutoTask(pTask); // take ownership immediately FastMutex::ScopedLock lock(_mutex); @@ -52,7 +51,7 @@ void TaskManager::start(Task* pTask) _taskList.push_back(pAutoTask); try { - _threadPool.start(*pAutoTask, pAutoTask->name()); + _threadPool.start(*pAutoTask, pAutoTask->name(), cpu); } catch (...) { diff --git a/Foundation/src/ThreadPool.cpp b/Foundation/src/ThreadPool.cpp index 61ab36299..7051b81a4 100644 --- a/Foundation/src/ThreadPool.cpp +++ b/Foundation/src/ThreadPool.cpp @@ -550,13 +550,14 @@ public: { delete _pPool; } - ThreadPool* pool() + ThreadPool* pool(ThreadPool::ThreadAffinityPolicy affinityPolicy = ThreadPool::OS_DEFAULT) { FastMutex::ScopedLock lock(_mutex); if (!_pPool) { _pPool = new ThreadPool("default"); + _pPool->setAffinityPolicy(affinityPolicy); if (POCO_THREAD_STACK_SIZE > 0) _pPool->setStackSize(POCO_THREAD_STACK_SIZE); } @@ -575,9 +576,9 @@ namespace } -ThreadPool& ThreadPool::defaultPool() +ThreadPool& ThreadPool::defaultPool(ThreadAffinityPolicy affinityPolicy) { - return *sh.pool(); + return *sh.pool(affinityPolicy); } diff --git a/Foundation/testsuite/src/TaskManagerTest.cpp b/Foundation/testsuite/src/TaskManagerTest.cpp index 6deb5c50b..43910636e 100644 --- a/Foundation/testsuite/src/TaskManagerTest.cpp +++ b/Foundation/testsuite/src/TaskManagerTest.cpp @@ -246,7 +246,7 @@ TaskManagerTest::~TaskManagerTest() void TaskManagerTest::testFinish() { - TaskManager tm; + TaskManager tm(ThreadPool::UNIFORM_DISTRIBUTION); TaskObserver to; tm.addObserver(Observer(to, &TaskObserver::taskStarted)); tm.addObserver(Observer(to, &TaskObserver::taskCancelled)); @@ -281,7 +281,7 @@ void TaskManagerTest::testFinish() void TaskManagerTest::testCancel() { - TaskManager tm; + TaskManager tm(ThreadPool::UNIFORM_DISTRIBUTION); TaskObserver to; tm.addObserver(Observer(to, &TaskObserver::taskStarted)); tm.addObserver(Observer(to, &TaskObserver::taskCancelled)); @@ -315,7 +315,7 @@ void TaskManagerTest::testCancel() void TaskManagerTest::testError() { - TaskManager tm; + TaskManager tm(ThreadPool::UNIFORM_DISTRIBUTION); TaskObserver to; tm.addObserver(Observer(to, &TaskObserver::taskStarted)); tm.addObserver(Observer(to, &TaskObserver::taskCancelled)); @@ -348,7 +348,7 @@ void TaskManagerTest::testError() void TaskManagerTest::testCustom() { - TaskManager tm; + TaskManager tm(ThreadPool::UNIFORM_DISTRIBUTION); CustomTaskObserver ti(0); tm.addObserver( @@ -431,7 +431,7 @@ void TaskManagerTest::testCustom() void TaskManagerTest::testMultiTasks() { - TaskManager tm; + TaskManager tm(ThreadPool::UNIFORM_DISTRIBUTION); tm.start(new SimpleTask); tm.start(new SimpleTask); tm.start(new SimpleTask); @@ -447,7 +447,7 @@ void TaskManagerTest::testMultiTasks() void TaskManagerTest::testCustomThreadPool() { - ThreadPool tp(2, 5, 120); + ThreadPool tp(2, 5, 120, POCO_THREAD_STACK_SIZE, ThreadPool::UNIFORM_DISTRIBUTION); TaskManager tm(tp); // fill up the thread pool From 6b7c87bf5cecbf20d73de4164b6abb2e77b2be2f Mon Sep 17 00:00:00 2001 From: bas524 Date: Tue, 17 Mar 2015 08:33:05 +0300 Subject: [PATCH 3/4] replace typedef enum to pure enum ThreadAffinityPolicy fix problem in cmake for pthread_setaffinity_np --- Foundation/CMakeLists.txt | 13 ++++++++----- Foundation/include/Poco/ThreadPool.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index d21fafdee..d51de92d8 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -111,11 +111,14 @@ add_definitions( -DPCRE_STATIC) if(UNIX AND NOT APPLE) INCLUDE (CheckFunctionExists) INCLUDE (CheckCXXSourceCompiles) - CHECK_FUNCTION_EXISTS(pthread_setaffinity_np HAVE_PTHREAD_SETAFFINITY_NP) - if(HAVE_PTHREAD_SETAFFINITY_NP) - message(STATUS "Platform has PTHREAD_SETAFFINITY_NP") - add_definitions(-DHAVE_PTHREAD_SETAFFINITY_NP) + INCLUDE (CheckLibraryExists) + CHECK_LIBRARY_EXISTS(pthread pthread_setaffinity_np "pthread.h" HAVE_PTHREAD_SETAFFINITY_NP) + #set(CMAKE_EXTRA_INCLUDE_FILES pthread.h) + #CHECK_FUNCTION_EXISTS(pthread_setaffinity_np HAVE_PTHREAD_SETAFFINITY_NP) + if(NOT HAVE_PTHREAD_SETAFFINITY_NP) + message(STATUS "Platform has not PTHREAD_SETAFFINITY_NP") else(HAVE_PTHREAD_SETAFFINITY_NP) + add_definitions(-DHAVE_PTHREAD_SETAFFINITY_NP) CHECK_CXX_SOURCE_COMPILES(" #include int main() { @@ -142,7 +145,7 @@ if(UNIX AND NOT APPLE) endif(HAVE_TWO_PARAM_SCHED_SETAFFINITY) endif(HAVE_THREE_PARAM_SCHED_SETAFFINITY) - endif(HAVE_PTHREAD_SETAFFINITY_NP) + endif(NOT HAVE_PTHREAD_SETAFFINITY_NP) endif(UNIX AND NOT APPLE) add_library( "${LIBNAME}" ${LIB_MODE} ${SRCS}) diff --git a/Foundation/include/Poco/ThreadPool.h b/Foundation/include/Poco/ThreadPool.h index 42fe35fa2..a11aa15a2 100644 --- a/Foundation/include/Poco/ThreadPool.h +++ b/Foundation/include/Poco/ThreadPool.h @@ -48,12 +48,12 @@ class Foundation_API ThreadPool /// from the pool. { public: - typedef enum _ThreadAffinityPolicy + enum _ThreadAffinityPolicy { OS_DEFAULT = 0, UNIFORM_DISTRIBUTION, CUSTOM - } ThreadAffinityPolicy; + }; ThreadPool(int minCapacity = 2, int maxCapacity = 16, From 283e9a959528670a5c07f0d5039da0705b01d45e Mon Sep 17 00:00:00 2001 From: bas524 Date: Tue, 17 Mar 2015 09:07:26 +0300 Subject: [PATCH 4/4] fix error --- Foundation/include/Poco/ThreadPool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Foundation/include/Poco/ThreadPool.h b/Foundation/include/Poco/ThreadPool.h index a11aa15a2..121e02ed0 100644 --- a/Foundation/include/Poco/ThreadPool.h +++ b/Foundation/include/Poco/ThreadPool.h @@ -48,7 +48,7 @@ class Foundation_API ThreadPool /// from the pool. { public: - enum _ThreadAffinityPolicy + enum ThreadAffinityPolicy { OS_DEFAULT = 0, UNIFORM_DISTRIBUTION,