mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-22 09:16:27 -06:00
Merge pull request #331 from andlaus/function_tasklets
tasklets: allow to dispatch raw functions
This commit is contained in:
commit
fbb885f303
@ -62,6 +62,15 @@ private:
|
||||
int mseconds_;
|
||||
};
|
||||
|
||||
void sleepAndPrintFunction()
|
||||
{
|
||||
int ms = 100;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||
outputMutex.lock();
|
||||
std::cout << "Sleep completed by worker thread " << runner->workerThreadIndex() << std::endl;
|
||||
outputMutex.unlock();
|
||||
}
|
||||
|
||||
int SleepTasklet::numInstantiated_ = 0;
|
||||
|
||||
int main()
|
||||
@ -83,10 +92,8 @@ int main()
|
||||
runner->barrier();
|
||||
std::cout << "after barrier" << std::endl;
|
||||
|
||||
for (int i = 0; i < 7; ++ i) {
|
||||
auto st = std::make_shared<SleepTasklet>(500);
|
||||
runner->dispatch(st);
|
||||
}
|
||||
runner->dispatchFunction(sleepAndPrintFunction);
|
||||
runner->dispatchFunction(sleepAndPrintFunction, /*numInvokations=*/6);
|
||||
|
||||
delete runner;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user