#include <SerialTaskQueueChain.h>
Definition at line 31 of file SerialTaskQueueChain.h.
edm::SerialTaskQueueChain::SerialTaskQueueChain |
( |
| ) |
|
|
inline |
edm::SerialTaskQueueChain::SerialTaskQueueChain |
( |
std::vector< std::shared_ptr< SerialTaskQueue >> |
iQueues | ) |
|
|
inlineexplicit |
Definition at line 39 of file SerialTaskQueueChain.h.
std::vector< std::shared_ptr< SerialTaskQueue > > m_queues
std::atomic< unsigned long > m_outstandingTasks
template<typename T >
void SerialTaskQueueChain::actionToRun |
( |
T && |
iAction | ) |
|
|
private |
Definition at line 138 of file SerialTaskQueueChain.h.
Referenced by passDownChain(), and push().
140 using Queues = std::vector<std::shared_ptr<SerialTaskQueue>>;
142 auto& vec = iChain->m_queues;
143 for (
auto it = vec.rbegin() + 1; it != vec.rend(); ++it) {
146 --(iChain->m_outstandingTasks);
149 std::unique_ptr<SerialTaskQueueChain, decltype(sentryAction)> sentry(
this, sentryAction);
std::size_t edm::SerialTaskQueueChain::numberOfQueues |
( |
| ) |
const |
|
inline |
unsigned long edm::SerialTaskQueueChain::outstandingTasks |
( |
| ) |
const |
|
inline |
template<typename T >
void SerialTaskQueueChain::passDownChain |
( |
unsigned int |
iIndex, |
|
|
T && |
iAction |
|
) |
| |
|
private |
Definition at line 124 of file SerialTaskQueueChain.h.
References actionToRun(), and m_queues.
Referenced by push().
129 if (iQueueIndex + 1 ==
m_queues.size()) {
132 auto nextQueue = iQueueIndex + 1;
133 m_queues[iQueueIndex]->push([
this, nextQueue, iAction]()
mutable { this->
passDownChain(nextQueue, iAction); });
std::vector< std::shared_ptr< SerialTaskQueue > > m_queues
void passDownChain(unsigned int iIndex, T &&iAction)
void actionToRun(T &&iAction)
template<typename T >
void SerialTaskQueueChain::push |
( |
T && |
iAction | ) |
|
asynchronously pushes functor iAction into queue
The function will return immediately and iAction will either process concurrently with the calling thread or wait until the protected resource becomes available or until a CPU becomes available.
- Parameters
-
[in] | iAction | Must be a functor that takes no arguments and return no values. |
Definition at line 85 of file SerialTaskQueueChain.h.
References actionToRun(), m_outstandingTasks, m_queues, and passDownChain().
Referenced by edm::EventProcessor::beginLumiAsync(), edm::EventProcessor::handleNextEventForStreamAsync(), operator=(), edm::InputProductResolver::prefetchAsync_(), edm::Worker::TaskQueueAdaptor::push(), pushAndWait(), and edm::ReducedProvenanceReader::ReducedProvenanceReader().
std::vector< std::shared_ptr< SerialTaskQueue > > m_queues
std::atomic< unsigned long > m_outstandingTasks
void passDownChain(unsigned int iIndex, T &&iAction)
void actionToRun(T &&iAction)
template<typename T >
void SerialTaskQueueChain::pushAndWait |
( |
T && |
iAction | ) |
|
synchronously pushes functor iAction into queue
The function will wait until iAction has completed before returning. If another task is already running on the queue, the system is allowed to find another TBB task to execute while waiting for the iAction to finish. In that way the core is not idled while waiting.
- Parameters
-
[in] | iAction | Must be a functor that takes no arguments and return no values. |
Definition at line 96 of file SerialTaskQueueChain.h.
References TauDecayModes::dec, push(), and TrackValidation_cff::task.
Referenced by operator=(), and edm::Worker::TaskQueueAdaptor::pushAndWait().
97 auto destry = [](
tbb::task* iTask) { tbb::task::destroy(*iTask); };
99 std::unique_ptr<tbb::task, decltype(destry)> waitTask(
new (tbb::task::allocate_root()) tbb::empty_task, destry);
100 waitTask->set_ref_count(3);
102 std::exception_ptr ptr;
103 auto waitTaskPtr = waitTask.get();
104 push([waitTaskPtr, iAction, &ptr]() {
106 auto dec = [](
tbb::task* iTask) { iTask->decrement_ref_count(); };
107 std::unique_ptr<tbb::task, decltype(dec)> sentry(waitTaskPtr,
dec);
111 ptr = std::current_exception();
115 waitTask->decrement_ref_count();
116 waitTask->wait_for_all();
119 std::rethrow_exception(ptr);
void push(T &&iAction)
asynchronously pushes functor iAction into queue
std::atomic<unsigned long> edm::SerialTaskQueueChain::m_outstandingTasks {0} |
|
private |
std::vector<std::shared_ptr<SerialTaskQueue> > edm::SerialTaskQueueChain::m_queues |
|
private |