- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
This

Returns a function which, when called, defers a call to the original function to the strand.

If the strand has been joined, the returned function will be a no-op.

code provides a function to set a data from within the strand:

Strand strand;
int data = 0;
auto dataSetter = [&](int i){ data = i };
auto safeDataSetter = strand.schedulerFor(dataSetter);
safeDataSetter(42);

Since the strand prevents concurrent calls, the data is safely set if this setter is used.

If the function was already asynchronous (returning a qi::Future<T>), the returned function will return a qi::Future<qi::Future<T>>, that you can choose to unwrap.

If you want the return type of the transformed function to remain a qi::Future<T>,

See Also
  unwrappedSchedulerFor.

Note
  Using std::bind with arguments wrapped in std::ref on a function transformed with schedulerFor may have counter-intuitive effects. STL's invocation of the bound function will lose the std::ref, so that when the deferred call is performed, the reference will not be recognized, and the argument will be copied to the target function.