27#ifndef OPM_TASKLETS_HPP
28#define OPM_TASKLETS_HPP
31#include <condition_variable>
52 virtual void run() = 0;
53 virtual bool isEndMarker ()
const {
return false; }
56 { -- referenceCount_; }
58 int referenceCount()
const
59 {
return referenceCount_; }
105 unsigned numWorkers_;
106 unsigned numWaiting_;
108 std::condition_variable barrierCondition_;
109 std::mutex barrierMutex_;
120 bool isEndMarker()
const override
145 bool failure()
const;
158 {
return threads_.size(); }
193 std::atomic<bool> failureFlag_ =
false;
202 std::vector<std::unique_ptr<std::thread> > threads_;
203 std::queue<std::shared_ptr<TaskletInterface> > taskletQueue_;
204 std::mutex taskletQueueMutex_;
205 std::condition_variable workAvailableCondition_;
208 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:71
The base class for tasklets.
Definition tasklets.hpp:45
Handles where a given tasklet is run.
Definition tasklets.hpp:93
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:157
void run_()
do the work until the queue received an end tasklet
Definition tasklets.cpp:157
~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:135
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:171
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 blackoilbioeffectsmodules.hh:43
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240