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()
|
||||
{
|
||||
if (!GetDeferredInitializers().get())
|
||||
auto& initializers = GetDeferredInitializers();
|
||||
if (!initializers.get())
|
||||
return;
|
||||
|
||||
while (!GetDeferredInitializers().get()->empty()) {
|
||||
DeferredInitializer initializer = GetDeferredInitializers().get()->top();
|
||||
GetDeferredInitializers().get()->pop();
|
||||
while (!initializers->empty()) {
|
||||
DeferredInitializer initializer = initializers->top();
|
||||
initializers->pop();
|
||||
initializer();
|
||||
}
|
||||
}
|
||||
|
||||
void Loader::AddDeferredInitializer(const std::function<void()>& callback, InitializePriority priority)
|
||||
{
|
||||
if (!GetDeferredInitializers().get())
|
||||
GetDeferredInitializers().reset(new Loader::DeferredInitializerPriorityQueue());
|
||||
auto& initializers = GetDeferredInitializers();
|
||||
if (!initializers.get()) {
|
||||
initializers.reset(new Loader::DeferredInitializerPriorityQueue());
|
||||
}
|
||||
|
||||
GetDeferredInitializers().get()->push(DeferredInitializer(callback, priority));
|
||||
initializers->push(DeferredInitializer(callback, priority));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue