mirror of https://github.com/Icinga/icinga2.git
Avoid calling `GetDeferredInitializers()` repeatedly
This commit is contained in:
parent
bb99106926
commit
38313434d2
|
@ -15,21 +15,24 @@ boost::thread_specific_ptr<Loader::DeferredInitializerPriorityQueue>& Loader::Ge
|
||||||
|
|
||||||
void Loader::ExecuteDeferredInitializers()
|
void Loader::ExecuteDeferredInitializers()
|
||||||
{
|
{
|
||||||
if (!GetDeferredInitializers().get())
|
auto& initializers = GetDeferredInitializers();
|
||||||
|
if (!initializers.get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (!GetDeferredInitializers().get()->empty()) {
|
while (!initializers->empty()) {
|
||||||
DeferredInitializer initializer = GetDeferredInitializers().get()->top();
|
DeferredInitializer initializer = initializers->top();
|
||||||
GetDeferredInitializers().get()->pop();
|
initializers->pop();
|
||||||
initializer();
|
initializer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loader::AddDeferredInitializer(const std::function<void()>& callback, InitializePriority priority)
|
void Loader::AddDeferredInitializer(const std::function<void()>& callback, InitializePriority priority)
|
||||||
{
|
{
|
||||||
if (!GetDeferredInitializers().get())
|
auto& initializers = GetDeferredInitializers();
|
||||||
GetDeferredInitializers().reset(new Loader::DeferredInitializerPriorityQueue());
|
if (!initializers.get()) {
|
||||||
|
initializers.reset(new Loader::DeferredInitializerPriorityQueue());
|
||||||
|
}
|
||||||
|
|
||||||
GetDeferredInitializers().get()->push(DeferredInitializer(callback, priority));
|
initializers->push(DeferredInitializer(callback, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue