Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
ola::CallbackRunner< CallbackClass > Class Template Reference

Detailed Description

template<typename CallbackClass>
class ola::CallbackRunner< CallbackClass >

Automatically execute a callback when it goes out of scope.

Template Parameters
CallbackClassAn class which has a Run() method.

This is useful if the function or method has multiple return points and you need to ensure that the callback is always executed before the function returns. It's most useful for handling RPCs.

Example
int Foo(MyCallback *callback) {
CallbackRunner runner(callback);
if (...) {
// do something here.
return 1;
} else {
if (...) {
// do something here.
return 2;
} else {
// do something here.
return 3;
}
}
}

Public Member Functions

 CallbackRunner (CallbackClass *callback)
 ~CallbackRunner ()

Constructor & Destructor Documentation

template<typename CallbackClass >
ola::CallbackRunner< CallbackClass >::CallbackRunner ( CallbackClass *  callback)
inlineexplicit

Construct a new CallbackRunner.

Parameters
callbackthe Callback to execute.
template<typename CallbackClass >
ola::CallbackRunner< CallbackClass >::~CallbackRunner ( )
inline

Destructor, this executes the callback.


The documentation for this class was generated from the following file: