![]() |
This method will make sure the action is scheduled to run on the target
locality. Applying the action itself does not wait for the function to
start running or to complete, instead this is a fully asynchronous operation
similar to using hpx::apply
as described above. The difference is that this method will return an
instance of a hpx::future<>
encapsulating the result of the (possibly remote) execution. The future
can be used to synchronize with the asynchronous operation. The following
example shows how to apply the action from above on the local locality:
some_global_action act; // define an instance of some_global_action hpx::future<void> f = hpx::async(act, hpx::find_here(), 2.0); // // ... other code can be executed here // f.get(); // this will possibly wait for the asyncronous operation to 'return'
(as before, the function hpx::find_here()
returns the id of the local locality
(the locality this code is executed on).
![]() |
Note |
---|---|
The use of a |
![]() |
Note |
---|---|
Any |
Any component member function can be invoked using the same syntactic
construct. Given that id
is the global address for a component instance created earlier, this
invocation looks like:
some_component_action act; // define an instance of some_component_action hpx::future<int> f = hpx::async(act, id, "42"); // // ... other code can be executed here // cout << f.get(); // this will possibly wait for the asyncronous operation to 'return' 42
![]() |
Note |
---|---|
The invocation of |