Type info
Title Executing functors in VCL solar thread
Posted by [EMAIL PROTECTED]
Affected -,
Effective from cws dbo510


Summary

header file: vcl/threadex.hxx


[namespace vcl::solarthread]
+ template <[typename ResultT,] typename FuncT> inline ResultT syncExecute( FuncT const& func );
+ template <typename T> inline detail::copy_back_wrapper<T> inout_by_ref( T & r );
+ template <typename T> inline detail::copy_back_wrapper<T> inout_by_ptr( T * p );


Description
/** 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 UNO exception that came up calling the functor in the solar thread
will be caught and rethrown in the calling thread. Any non-UNO
exception needs to be handled by the called functor.
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 boost::cref()/boost::ref() or similar for objects on
your thread's stack.
Use inout_by_ref() or inout_by_ptr() for this purpose, e.g.

<pre>
using namespace vcl::solarthread;

long n = 3;
// calling foo( long & r ):
syncExecute( boost::bind( &foo, inout_by_ref(n) ) );
// calling foo( long * p ):
syncExecute( boost::bind( &foo, inout_by_ptr(&n) ) );

char const* pc = "default";
// calling foo( char const** ppc ):
syncExecute( boost::bind( &foo, inout_by_ptr(&pc) ) );
// calling foo( char const*& rpc ):
syncExecute( boost::bind( &foo, inout_by_ref(pc) ) );
</pre>

@tpl ResultT result type, defaults to FuncT::result_type to seamlessly
support mem_fn and bind
@tpl FuncT functor type, let your compiler deduce this type
@param func functor object to be executed in solar thread
@return return value of functor
*/
template <typename ResultT, typename FuncT>
inline ResultT syncExecute( FuncT const& func );

template <typename FuncT>
inline typename FuncT::result_type syncExecute( FuncT const& func );

/** Makes a copy back reference wrapper to be used for inout parameters.
Only use for syncExecute(), the returned wrapper relies on its
implemenation, i.e. the function object is stored in free store.
Type T needs to be copy constructable assignable.

@see syncExecute()
@param r reference to a stack variable
@return reference wrapper
*/
template <typename T>
inline detail::copy_back_wrapper<T> inout_by_ref( T & r );

/** Makes a copy back ptr wrapper to be used for inout parameters.
Only use for syncExecute(), the returned wrapper relies on its
implemenation, i.e. the function object is stored in free store.
Type T needs to be copy constructable assignable.

@see syncExecute()
@param p pointer to a stack variable
@return ptr wrapper
*/
template <typename T>
inline detail::copy_back_wrapper<T> inout_by_ptr( T * p );


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to