diff --git a/include/lockSet.h b/include/lockSet.h index 00acc13..19dbedb 100644 --- a/include/lockSet.h +++ b/include/lockSet.h @@ -74,9 +74,8 @@ public: * cleaned up in the qutexQ's std::list destructor -- and that won't * execute any fancy cleanup logic. It'll just clear() out the list. */ - template void registerInQutexQueues( - const typename SerializedAsynchronousContinuation::template LockerAndInvoker &lockvoker); + const std::shared_ptr &lockvoker); /** * @brief Try to acquire all locks in order; back off if acquisition fails diff --git a/include/serializedAsynchronousContinuation.h b/include/serializedAsynchronousContinuation.h index f7f5d4d..796d637 100644 --- a/include/serializedAsynchronousContinuation.h +++ b/include/serializedAsynchronousContinuation.h @@ -253,6 +253,19 @@ public: void allowAwakening() { serializedContinuation.isAwakeOrBeingAwakened.store(false); } + /** EXPLANATION: + * Creates a shared_ptr copy of this lockvoker and registers it with + * the serialized continuation's LockSet. + */ + void registerInLockSet() + { + auto sharedLockvoker = std::make_shared< + LockerAndInvoker>(*this); + + serializedContinuation.requiredLocks.registerInQutexQueues( + sharedLockvoker); + } + /** * @brief First wake - register in queues and awaken * @@ -263,7 +276,7 @@ public: void firstWake() { serializedContinuation.isAwakeOrBeingAwakened.store(true); - serializedContinuation.requiredLocks.registerInQutexQueues(*this); + registerInLockSet(); // Force awaken since we just set the flag above awaken(true); } diff --git a/smocore/lockSet.cpp b/smocore/lockSet.cpp index d180fce..15a98c6 100644 --- a/smocore/lockSet.cpp +++ b/smocore/lockSet.cpp @@ -7,9 +7,8 @@ namespace smo { // These will be explicitly instantiated for the types we need template -template void LockSet::registerInQutexQueues( - const typename SerializedAsynchronousContinuation::template LockerAndInvoker &lockvoker + const std::shared_ptr &lockvoker ) { /** EXPLANATION: @@ -34,13 +33,10 @@ void LockSet::registerInQutexQueues( * io_service, potentially without being executed if they fail to * acquire all locks. */ - auto sharedLockvoker = std::make_shared< - typename SerializedAsynchronousContinuation::template LockerAndInvoker>(lockvoker); - for (auto& lockUsageDesc : locks) { lockUsageDesc.second = lockUsageDesc.first.get().registerInQueue( - sharedLockvoker); + lockvoker); } registeredInQutexQueues = true;