Skip to content

Commit

Permalink
simplify branching
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelarguedas committed Feb 8, 2018
1 parent 6af51e5 commit 71a3d3e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
36 changes: 19 additions & 17 deletions include/class_loader/class_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,30 +208,32 @@ class ClassLoader
void onPluginDeletion(Base * obj)
{
CONSOLE_BRIDGE_logDebug(
"class_loader::ClassLoader: Calling onPluginDeletion() for obj ptr = %p.\n", obj);
if (obj) {
boost::recursive_mutex::scoped_lock lock(plugin_ref_count_mutex_);
"class_loader::ClassLoader: Calling onPluginDeletion() for obj ptr = %p.\n",
reinterpret_cast<void *>(obj));
if (nullptr == obj) {
return;
}
boost::recursive_mutex::scoped_lock lock(plugin_ref_count_mutex_);
#ifndef _WIN32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#endif
delete (obj);
delete (obj);
#ifndef _WIN32
#pragma GCC diagnostic pop
#endif
plugin_ref_count_ = plugin_ref_count_ - 1;
assert(plugin_ref_count_ >= 0);
if (0 == plugin_ref_count_ && isOnDemandLoadUnloadEnabled()) {
if (!ClassLoader::hasUnmanagedInstanceBeenCreated()) {
unloadLibraryInternal(false);
} else {
CONSOLE_BRIDGE_logWarn(
"class_loader::ClassLoader: "
"Cannot unload library %s even though last shared pointer went out of scope. "
"This is because createUnmanagedInstance was used within the scope of this process,"
" perhaps by a different ClassLoader. Library will NOT be closed.",
getLibraryPath().c_str());
}
plugin_ref_count_ = plugin_ref_count_ - 1;
assert(plugin_ref_count_ >= 0);
if (0 == plugin_ref_count_ && isOnDemandLoadUnloadEnabled()) {
if (!ClassLoader::hasUnmanagedInstanceBeenCreated()) {
unloadLibraryInternal(false);
} else {
CONSOLE_BRIDGE_logWarn(
"class_loader::ClassLoader: "
"Cannot unload library %s even though last shared pointer went out of scope. "
"This is because createUnmanagedInstance was used within the scope of this process,"
" perhaps by a different ClassLoader. Library will NOT be closed.",
getLibraryPath().c_str());
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions include/class_loader/multi_library_class_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,13 @@ class MultiLibraryClassLoader
std::vector<std::string> getAvailableClassesForLibrary(const std::string & library_path)
{
ClassLoader * loader = getClassLoaderForLibrary(library_path);
std::vector<std::string> available_classes;
if (loader) {
available_classes = loader->getAvailableClasses<Base>();
return available_classes;
} else {
if (nullptr == loader) {
throw class_loader::NoClassLoaderExistsException(
"There is no ClassLoader in MultiLibraryClassLoader bound to library " +
library_path +
" Ensure you called MultiLibraryClassLoader::loadLibrary()");
}
return loader->getAvailableClasses<Base>();
}

/**
Expand Down

0 comments on commit 71a3d3e

Please sign in to comment.