LibreOffice Module vcl (master) 1
Namespaces | Functions
vcl::solarthread Namespace Reference

Namespaces

namespace  detail
 

Functions

template<typename FuncT >
auto syncExecute (FuncT const &func) -> decltype(func())
 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. More...
 

Function Documentation

◆ syncExecute()

template<typename FuncT >
auto vcl::solarthread::syncExecute ( FuncT const &  func) -> decltype(func())
inline

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.

using namespace vcl::solarthread;
long n = 3;
// calling foo( long & r ):
syncExecute( std::bind( &foo, inout_by_ref(n) ) );
// calling foo( long * p ):
syncExecute( std::bind( &foo, inout_by_ptr(&n) ) );
char const* pc = "default";
// calling foo( char const** ppc ):
syncExecute( std::bind( &foo, inout_by_ptr(&pc) ) );
// calling foo( char const*& rpc ):
syncExecute( std::bind( &foo, inout_by_ref(pc) ) );
sal_Int64 n
auto syncExecute(FuncT const &func) -> decltype(func())
This function will execute the passed functor synchronously in the solar thread, thus the calling thr...
Definition: threadex.hxx:165
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
funcfunctor object to be executed in solar thread
Returns
return value of functor

Definition at line 165 of file threadex.hxx.