mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -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_;
|
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 SleepTasklet::numInstantiated_ = 0;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -83,10 +92,8 @@ int main()
|
|||||||
runner->barrier();
|
runner->barrier();
|
||||||
std::cout << "after barrier" << std::endl;
|
std::cout << "after barrier" << std::endl;
|
||||||
|
|
||||||
for (int i = 0; i < 7; ++ i) {
|
runner->dispatchFunction(sleepAndPrintFunction);
|
||||||
auto st = std::make_shared<SleepTasklet>(500);
|
runner->dispatchFunction(sleepAndPrintFunction, /*numInvokations=*/6);
|
||||||
runner->dispatch(st);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete runner;
|
delete runner;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user