Add LoadableLibraryManager and refactor StimBuffApiManager to use it.
Centralize dlopen/search in LoadableLibraryManager so typed library managers can share one loaded-shlib registry without duplicating load/unload logic. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <deviceManager/deviceManager.h>
|
||||
#include <deviceManager/deviceReattacher.h>
|
||||
#include <stimBuffApis/stimBuffApiManager.h>
|
||||
#include <loadableLib/loadableLibraryManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <marionette/marionetteThread.h>
|
||||
#include <mind.h>
|
||||
@@ -92,7 +93,7 @@ DeviceManager::attachStimBuffDeviceCReq(
|
||||
auto &sbam = stim_buff::StimBuffApiManager::getInstance();
|
||||
auto &lib = sbam.getStimBuffApiLibByApiName(spec->stimBuffApi);
|
||||
|
||||
if (lib.isBeingDestroyed.load())
|
||||
if (lib.loadedSharedLibrary->isBeingDestroyed.load())
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": Library is being destroyed"
|
||||
@@ -103,12 +104,13 @@ DeviceManager::attachStimBuffDeviceCReq(
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": attachDeviceCReq() is NULL "
|
||||
"for library '" + lib.libraryPath + "'");
|
||||
"for library '" + lib.loadedSharedLibrary->libraryPath + "'");
|
||||
}
|
||||
|
||||
/* FIXME Locking here makes no sense. */
|
||||
sscl::co::CoQutex::ReleaseHandle sbamGuard =
|
||||
co_await sbam.s.lock.getAcquireInvocationAndSuspensionPolicy();
|
||||
co_await sbam.s.lock
|
||||
.getAcquireInvocationAndSuspensionPolicy();
|
||||
sscl::co::CoQutex::ReleaseHandle libGuard =
|
||||
co_await lib.s.lock.getAcquireInvocationAndSuspensionPolicy();
|
||||
sbamGuard.release();
|
||||
@@ -151,7 +153,7 @@ DeviceManager::detachStimBuffDeviceCReq(
|
||||
auto &sbam = stim_buff::StimBuffApiManager::getInstance();
|
||||
auto &lib = sbam.getStimBuffApiLibByApiName(spec->stimBuffApi);
|
||||
|
||||
if (lib.isBeingDestroyed.load())
|
||||
if (lib.loadedSharedLibrary->isBeingDestroyed.load())
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": Library is being destroyed"
|
||||
@@ -162,12 +164,13 @@ DeviceManager::detachStimBuffDeviceCReq(
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": detachDeviceCReq() is NULL "
|
||||
"for library '" + lib.libraryPath + "'");
|
||||
"for library '" + lib.loadedSharedLibrary->libraryPath + "'");
|
||||
}
|
||||
|
||||
/* FIXME Locking here makes no sense. */
|
||||
sscl::co::CoQutex::ReleaseHandle sbamGuard =
|
||||
co_await sbam.s.lock.getAcquireInvocationAndSuspensionPolicy();
|
||||
co_await sbam.s.lock
|
||||
.getAcquireInvocationAndSuspensionPolicy();
|
||||
sscl::co::CoQutex::ReleaseHandle libGuard =
|
||||
co_await lib.s.lock.getAcquireInvocationAndSuspensionPolicy();
|
||||
sbamGuard.release();
|
||||
|
||||
Reference in New Issue
Block a user