aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstate.cpp')
-rw-r--r--src/libstate.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/libstate.cpp b/src/libstate.cpp
index 8d6475e64..04a5760cb 100644
--- a/src/libstate.cpp
+++ b/src/libstate.cpp
@@ -311,7 +311,6 @@ Config& Library_State::config() const
{
if(!config_obj)
{
- printf("Lazy creation of the global config\n");
config_obj = new Config();
config_obj->load_defaults();
}
@@ -320,16 +319,23 @@ Config& Library_State::config() const
}
/*************************************************
-* Library_State Constructor *
+* Load a set of modules *
*************************************************/
-Library_State::Library_State(const InitializerOptions& args,
- Modules& modules)
+void Library_State::initialize(const InitializerOptions& args,
+ Modules& modules)
{
+ if(mutex_factory)
+ throw Invalid_State("Library_State has already been initialized");
+
if(args.thread_safe())
mutex_factory = modules.mutex_factory();
else
mutex_factory = new Default_Mutex_Factory;
+ cached_default_allocator = 0;
+ x509_state_obj = 0;
+ ui = 0;
+
timer = modules.timer();
transcoder = modules.transcoder();
@@ -340,10 +346,6 @@ Library_State::Library_State(const InitializerOptions& args,
locks["allocator"] = get_mutex();
locks["rng"] = get_mutex();
locks["engine"] = get_mutex();
- rng = 0;
- cached_default_allocator = 0;
- x509_state_obj = 0;
- ui = 0;
std::vector<Allocator*> mod_allocs = modules.allocators();
for(u32bit j = 0; j != mod_allocs.size(); ++j)
@@ -379,6 +381,24 @@ Library_State::Library_State(const InitializerOptions& args,
}
/*************************************************
+* Library_State Constructor *
+*************************************************/
+Library_State::Library_State()
+ {
+ mutex_factory = 0;
+
+ timer = 0;
+ config_obj = 0;
+ x509_state_obj = 0;
+
+ ui = 0;
+ transcoder = 0;
+ rng = 0;
+ cached_default_allocator = 0;
+ ui = 0;
+ }
+
+/*************************************************
* Library_State Destructor *
*************************************************/
Library_State::~Library_State()