mirror of https://github.com/Icinga/icinga2.git
InitializeOnceHelper: use std::function instead of C function pointer
InitializeOnceHelper calls Loader::AddDeferredInitializer which takes a std::function, so it's eventually converted to that anyways. This commit just does this a bit earlier, and by saving the step of the intermediate C function pointer, this would now also work for capturing lambdas (which there are none of at the moment).
This commit is contained in:
parent
c019f8c04a
commit
61285adcae
|
@ -5,7 +5,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
bool icinga::InitializeOnceHelper(void (*func)(), int priority)
|
||||
bool icinga::InitializeOnceHelper(const std::function<void()>& func, int priority)
|
||||
{
|
||||
Loader::AddDeferredInitializer(func, priority);
|
||||
return true;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#define INITIALIZE_H
|
||||
|
||||
#include "base/i2-base.hpp"
|
||||
#include <functional>
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
@ -13,7 +14,7 @@ namespace icinga
|
|||
|
||||
#define I2_UNIQUE_NAME(prefix) I2_TOKENPASTE2(prefix, __COUNTER__)
|
||||
|
||||
bool InitializeOnceHelper(void (*func)(), int priority = 0);
|
||||
bool InitializeOnceHelper(const std::function<void()>& func, int priority = 0);
|
||||
|
||||
#define INITIALIZE_ONCE(func) \
|
||||
namespace { namespace I2_UNIQUE_NAME(io) { \
|
||||
|
|
Loading…
Reference in New Issue