[x265-commits] [x265] pool: separate worker thread stoppage from destructor
Steve Borho
steve at borho.org
Tue Mar 10 18:33:27 CET 2015
details: http://hg.videolan.org/x265/rev/23043a8a086f
branches:
changeset: 9672:23043a8a086f
user: Steve Borho <steve at borho.org>
date: Tue Mar 10 01:38:42 2015 -0500
description:
pool: separate worker thread stoppage from destructor
This allows us to stop the worker threads before any of the job providers are
deleted.
Subject: [x265] pool: Threadpool::stop will only stop all worker threads, not destruct them.
details: http://hg.videolan.org/x265/rev/82482eca92a8
branches:
changeset: 9673:82482eca92a8
user: Deepthi Nandakumar <deepthi at multicorewareinc.com>
date: Tue Mar 10 14:16:55 2015 +0530
description:
pool: Threadpool::stop will only stop all worker threads, not destruct them.
So, a worker thread pool can be stopped and restarted.
diffstat:
source/common/threadpool.cpp | 15 +++++++++++----
source/common/threadpool.h | 1 +
source/encoder/encoder.cpp | 2 ++
3 files changed, 14 insertions(+), 4 deletions(-)
diffs (58 lines):
diff -r 726fe4088f31 -r 82482eca92a8 source/common/threadpool.cpp
--- a/source/common/threadpool.cpp Mon Mar 09 19:21:25 2015 -0500
+++ b/source/common/threadpool.cpp Tue Mar 10 14:16:55 2015 +0530
@@ -371,7 +371,7 @@ bool ThreadPool::start()
return true;
}
-ThreadPool::~ThreadPool()
+void ThreadPool::stop()
{
if (m_workers)
{
@@ -380,12 +380,19 @@ ThreadPool::~ThreadPool()
{
m_workers[i].awaken();
m_workers[i].stop();
+ }
+ }
+}
+
+ThreadPool::~ThreadPool()
+{
+ if (m_workers)
+ {
+ for (int i = 0; i < m_numWorkers; i++)
m_workers[i].~WorkerThread();
- }
-
- X265_FREE(m_workers);
}
+ X265_FREE(m_workers);
X265_FREE(m_jpTable);
}
diff -r 726fe4088f31 -r 82482eca92a8 source/common/threadpool.h
--- a/source/common/threadpool.h Mon Mar 09 19:21:25 2015 -0500
+++ b/source/common/threadpool.h Tue Mar 10 14:16:55 2015 +0530
@@ -94,6 +94,7 @@ public:
bool create(int numThreads, int maxProviders, int node);
bool start();
+ void stop();
void setCurrentThreadAffinity();
int tryAcquireSleepingThread(sleepbitmap_t firstTryBitmap, sleepbitmap_t secondTryBitmap);
int tryBondPeers(int maxPeers, sleepbitmap_t peerBitmap, BondedTaskGroup& master);
diff -r 726fe4088f31 -r 82482eca92a8 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Mon Mar 09 19:21:25 2015 -0500
+++ b/source/encoder/encoder.cpp Tue Mar 10 14:16:55 2015 +0530
@@ -296,6 +296,8 @@ void Encoder::stop()
m_frameEncoder[i]->stop();
}
}
+
+ m_threadPool->stop();
}
void Encoder::destroy()
More information about the x265-commits
mailing list