Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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.

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)

Construct a new CallbackRunner.

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

Destructor, this executes the callback.

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