MT#63171 add AmSessionProcessor::stopThreads

Method to stop all AmSessionProcessor threads that have been created.

Change-Id: Ib339c72c5f7b3372f1d611c0e77c08e2f21a65d7
mr13.5
Richard Fuchs 1 year ago
parent 01345c60e7
commit f9b93e343a

@ -68,6 +68,21 @@ void AmSessionProcessor::addThreads(unsigned int num_threads) {
DBG("now %zd session processor threads running\n", threads.size());
}
void AmSessionProcessor::stopThreads()
{
std::lock_guard<AmMutex> _l(threads_mut);
DBG("shutting down %zu session processor threads\n", threads.size());
// two-pass: first request stop, then join and delete
for (auto it = threads.begin(); it != threads.end(); it++)
(*it)->stop();
while (!threads.empty()) {
auto* thread = threads.back();
threads.pop_back();
thread->join();
delete thread;
}
}
AmSessionProcessorThread::AmSessionProcessorThread()
: events(this), runcond(false)

@ -50,6 +50,7 @@ class AmSessionProcessor {
public:
static AmSessionProcessorThread* getProcessorThread();
static void addThreads(unsigned int num_threads);
static void stopThreads();
};
struct AmSessionProcessorThreadAddEvent

@ -680,6 +680,11 @@ int main(int argc, char* argv[])
sd.stopping();
#ifdef SESSION_THREADPOOL
INFO("Starting session processor threads\n");
AmSessionProcessor::stopThreads();
#endif
INFO("Disposing plug-ins\n");
AmPlugIn::dispose();

Loading…
Cancel
Save