This function will execute the passed functor synchronously in the solar thread, thus the calling thread will (eventually) be blocked until the functor has been called.
Any exception that came up calling the functor in the solar thread will be caught and rethrown in the calling thread. The result type of this function needs to be default constructable. Please keep in mind not to pass addresses to stack variables (e.g. for out parameters) to foreign threads, use inout_by_ref() for this purpose. For in parameters, this may not affect you, because the functor object is copy constructed into free store. This way you must not use
std::cref()/std::ref()
or similar for objects on your thread's stack. Use inout_by_ref() or inout_by_ptr() for this purpose, e.g.
char const*
pc =
"default";
auto syncExecute(FuncT const &func) -> decltype(func())
This function will execute the passed functor synchronously in the solar thread, thus the calling thr...
- Template parameter: \n ResultT result type, defaults to FuncT::result_type to seamlessly
- support mem_fn and bind
- Template parameter: \n FuncT functor type, let your compiler deduce this type
- Parameters
-
func | functor object to be executed in solar thread |
- Returns
- return value of functor
Definition at line 165 of file threadex.hxx.