Documentation for concurrent and small improvements

git-svn-id: svn://db.shs.com.ru/pip@868 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
7 changed files with 87 additions and 26 deletions

View File

@@ -11,7 +11,8 @@ PIThreadPoolExecutor::PIThreadPoolExecutor(size_t corePoolSize, PIBlockingDequeu
auto runnable = taskQueue->poll(100, std::function<void()>());
if (runnable) {
runnable();
} else if (isShutdown_) threadPool[i]->stop();
}
if (isShutdown_ && taskQueue->size() == 0) threadPool[i]->stop();
});
threadPool.push_back(thread);
thread->start();
@@ -35,7 +36,6 @@ void PIThreadPoolExecutor::shutdownNow() {
PIThreadPoolExecutor::~PIThreadPoolExecutor() {
shutdownNow();
taskQueue->getConditionVar()->notifyAll();
while (threadPool.size() > 0) delete threadPool.take_back();
delete threadFactory;
delete taskQueue;
@@ -48,3 +48,7 @@ void PIThreadPoolExecutor::execute(const std::function<void()> &runnable) {
volatile bool PIThreadPoolExecutor::isShutdown() const {
return isShutdown_;
}
void PIThreadPoolExecutor::shutdown() {
isShutdown_ = true;
}