1 /******************************************************************************
3 * Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
23 #include "base/i2-base.hpp"
24 #include "base/string.hpp"
25 #include <boost/thread/tss.hpp>
26 #include <boost/function.hpp>
32 struct DeferredInitializer
35 DeferredInitializer(const boost::function<void (void)>& callback, int priority)
36 : m_Callback(callback), m_Priority(priority)
39 inline bool operator<(const DeferredInitializer& other) const
41 return m_Priority < other.m_Priority;
44 inline void operator()(void)
50 boost::function<void (void)> m_Callback;
55 * Loader helper functions.
59 class I2_BASE_API Loader
62 static void LoadExtensionLibrary(const String& library);
64 static void AddDeferredInitializer(const boost::function<void(void)>& callback, int priority = 0);
65 static void ExecuteDeferredInitializers(void);
70 static boost::thread_specific_ptr<std::priority_queue<DeferredInitializer> >& GetDeferredInitializers(void);