27#ifndef OPM_TASKLETS_HPP
28#define OPM_TASKLETS_HPP
34#include <condition_variable>
50 virtual void run() = 0;
51 virtual bool isEndMarker ()
const {
return false; }
54 { -- referenceCount_; }
56 int referenceCount()
const
57 {
return referenceCount_; }
102 unsigned numWorkers_;
103 unsigned numWaiting_;
105 std::condition_variable barrierCondition_;
106 std::mutex barrierMutex_;
117 bool isEndMarker()
const
142 bool failure()
const;
155 {
return threads_.size(); }
190 std::atomic<bool> failureFlag_ =
false;
199 std::vector<std::unique_ptr<std::thread> > threads_;
200 std::queue<std::shared_ptr<TaskletInterface> > taskletQueue_;
201 std::mutex taskletQueueMutex_;
202 std::condition_variable workAvailableCondition_;
205 static thread_local int workerThreadIndex_;
A simple tasklet that runs a function that returns void and does not take any arguments a given numbe...
Definition tasklets.hpp:69
The base class for tasklets.
Definition tasklets.hpp:44
Handles where a given tasklet is run.
Definition tasklets.hpp:90
int workerThreadIndex() const
Returns the index of the current worker thread.
Definition tasklets.cpp:94
int numWorkerThreads() const
Returns the number of worker threads for the tasklet runner.
Definition tasklets.hpp:154
void run_()
do the work until the queue received an end tasklet
Definition tasklets.cpp:156
~TaskletRunner()
Destructor.
Definition tasklets.cpp:77
void barrier()
Make sure that all tasklets have been completed after this method has been called.
Definition tasklets.cpp:134
std::shared_ptr< FunctionRunnerTasklet< Fn > > dispatchFunction(Fn &fn, int numInvocations=1)
Convenience method to construct a new function runner tasklet and dispatch it immediately.
Definition tasklets.hpp:168
void dispatch(std::shared_ptr< TaskletInterface > tasklet)
Add a new tasklet.
Definition tasklets.cpp:101
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242