Lightweight Control Objects provide synchronization for HPX applications. Most of them are familiar from other frameworks, but a few of them work in slightly special different ways adapted to HPX.
To call an application with a single guard, simply declare the guard and call run_guarded() with a function (task).
hpx::lcos::local::guard gu; run_guarded(gu,task);
If a single method needs to run with multiple guards, use a guard set.
boost::shared<hpx::lcos::local::guard> gu1(new hpx::lcos::local::guard()); boost::shared<hpx::lcos::local::guard> gu2(new hpx::lcos::local::guard()); gs.add(*gu1); gs.add(*gu2); run_guarded(gs,task);
Guards use two atomic operations (which are not called repeatedly) to manage what they do, so overhead should be extremely low.