Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
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;
}
}
}
Automatically execute a callback when it goes out of scope.
Definition CallbackRunner.h:82

Public Member Functions

 CallbackRunner (CallbackClass *callback)
 
 ~CallbackRunner ()
 

Constructor & Destructor Documentation

◆ CallbackRunner()

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

Construct a new CallbackRunner.

Parameters
callbackthe Callback to execute.

◆ ~CallbackRunner()

template<typename CallbackClass >
ola::CallbackRunner< CallbackClass >::~CallbackRunner ( )
inline

Destructor, this executes the callback.


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