Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/bthread/eloq_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
#include "bthread/bthread.h"

extern "C" {
bthread::TaskControl* bthread_get_task_control();
bthread::TaskControl *bthread_get_task_control();
}

extern std::array<eloq::EloqModule *, 10> registered_modules;
extern std::atomic<int> registered_module_cnt;

Expand All @@ -47,6 +48,17 @@ namespace eloq {
}

int unregister_module(EloqModule *module) {
// Verify that the module is currently registered.
std::shared_lock s_lk(module_mutex);
const bool exists = std::find(registered_modules.begin(),
registered_modules.end(),
module) != registered_modules.end();
if (!exists) {
LOG(WARNING) << "Attempted to unregister a non-registered module: " << module;
return -1;
}
s_lk.unlock();

const auto concurrency = bthread_get_task_control()->concurrency();
while (module->registered_workers_.load(std::memory_order_acquire) != concurrency) {
for (int thd_id = 0; thd_id < concurrency; ++thd_id) {
Expand Down
Loading