Skip to content

Commit

Permalink
capicxx-core-runtime 3.1.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Jan 25, 2018
1 parent 5152d31 commit 45a3dea
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 233 deletions.
158 changes: 0 additions & 158 deletions .cproject

This file was deleted.

42 changes: 0 additions & 42 deletions .gitattributes

This file was deleted.

2 changes: 0 additions & 2 deletions .gitignore

This file was deleted.

27 changes: 0 additions & 27 deletions .project

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Changes
=======
v3.1.12.2
- Defer Runtime destruction till shared object is unloaded

v3.1.12.1
- replaced std::chrono::high_resolution_clock by std::chrono::steady_clock in MainLoopContext.cpp

Expand Down
1 change: 0 additions & 1 deletion include/CommonAPI/Runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ class Runtime {
bool isInitialized_;

static std::map<std::string, std::string> properties_;
static std::shared_ptr<Runtime> theRuntime__;

friend class ProxyManager;
};
Expand Down
28 changes: 25 additions & 3 deletions src/CommonAPI/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,19 @@ const char *COMMONAPI_DEFAULT_CONFIG_FILE = "commonapi.ini";
const char *COMMONAPI_DEFAULT_CONFIG_FOLDER = "/etc";

std::map<std::string, std::string> properties__;
std::shared_ptr<Runtime> Runtime::theRuntime__ = std::make_shared<Runtime>();
static std::shared_ptr<Runtime> * theRuntimePtr__;
static std::mutex getMutex__;

#ifndef _WIN32
DEINITIALIZER(RuntimeDeinit) {
if (theRuntimePtr__) {
std::lock_guard<std::mutex> itsLock(getMutex__);
theRuntimePtr__->reset();
delete theRuntimePtr__;
theRuntimePtr__ = nullptr;
}
}
#endif

std::string
Runtime::getProperty(const std::string &_name) {
Expand All @@ -43,8 +55,18 @@ Runtime::setProperty(const std::string &_name, const std::string &_value) {
}

std::shared_ptr<Runtime> Runtime::get() {
theRuntime__->init();
return theRuntime__;
std::lock_guard<std::mutex> itsLock(getMutex__);
if(!theRuntimePtr__) {
theRuntimePtr__ = new std::shared_ptr<Runtime>();
}
if (theRuntimePtr__) {
if (!*theRuntimePtr__) {
*theRuntimePtr__ = std::make_shared<Runtime>();
(*theRuntimePtr__)->init();
}
return *theRuntimePtr__;
}
return nullptr;
}

Runtime::Runtime()
Expand Down

0 comments on commit 45a3dea

Please sign in to comment.