#include <ThreadHandoff.h>
Definition at line 33 of file ThreadHandoff.h.
ThreadHandoff::ThreadHandoff |
( |
int |
stackSize | ) |
|
|
explicit |
Definition at line 40 of file ThreadHandoff.cc.
References Exception, m_loopReady, m_mutex, m_thread, m_threadHandoff, and threadLoop().
43 if (0 != (erno = pthread_attr_init(&attr))) {
45 <<
"Failed to initialize thread attributes (" << erno <<
") " << errorMessage(erno);
48 if (0 != (erno = pthread_attr_setstacksize(&attr, stackSize))) {
50 <<
"Failed to set stack size " << stackSize <<
" " << errorMessage(erno);
52 std::unique_lock<std::mutex> lk(
m_mutex);
56 throw cms::Exception(
"ThreadCreateFailed") <<
" failed to create a pthread (" << erno <<
") " << errorMessage(erno);
std::condition_variable m_threadHandoff
static void * threadLoop(void *iArgs)
ThreadHandoff::~ThreadHandoff |
( |
| ) |
|
template<typename F >
void omt::ThreadHandoff::runAndWait |
( |
F && |
iF | ) |
|
|
inline |
Definition at line 42 of file ThreadHandoff.h.
References alignCSCRings::e, validate-o2o-wbm::f, m_loopReady, m_mutex, m_threadHandoff, m_toRun, and eostools::move().
Referenced by OscarMTProducer::beginRun(), OscarMTProducer::endRun(), OscarMTProducer::OscarMTProducer(), OscarMTProducer::produce(), stopThread(), and OscarMTProducer::~OscarMTProducer().
45 std::unique_lock<std::mutex> lck(
m_mutex);
52 auto e =
f.exception();
54 std::rethrow_exception(
e);
std::condition_variable m_threadHandoff
void omt::ThreadHandoff::stopThread |
( |
| ) |
|
|
inline |
void * ThreadHandoff::threadLoop |
( |
void * |
iArgs | ) |
|
|
staticprivate |
Definition at line 98 of file ThreadHandoff.cc.
Referenced by ThreadHandoff().
103 std::unique_lock<std::mutex> lck(theThis->m_mutex);
104 theThis->m_loopReady =
true;
105 theThis->m_threadHandoff.notify_one();
108 theThis->m_toRun =
nullptr;
109 theThis->m_threadHandoff.wait(lck, [theThis]() {
return nullptr != theThis->m_toRun; });
110 theThis->m_toRun->execute();
111 theThis->m_loopReady =
true;
112 theThis->m_threadHandoff.notify_one();
113 }
while (not theThis->m_stopThread);
114 theThis->m_loopReady =
true;
bool omt::ThreadHandoff::m_loopReady {false} |
|
private |
bool omt::ThreadHandoff::m_stopThread {false} |
|
private |
pthread_t omt::ThreadHandoff::m_thread |
|
private |
std::condition_variable omt::ThreadHandoff::m_threadHandoff |
|
private |