@@ -35,7 +35,7 @@ AutoPacket::~AutoPacket(void) {
3535 std::chrono::high_resolution_clock::now () - m_initTime
3636 )
3737 );
38-
38+
3939 // Mark decorations of successor packets that use decorations
4040 // originating from this packet as unsatisfiable
4141 for (auto & pair : m_decoration_map)
@@ -44,15 +44,15 @@ AutoPacket::~AutoPacket(void) {
4444
4545 // Needed for the AutoPacketGraph
4646 NotifyTeardownListeners ();
47-
47+
4848 // Create vector of all successor packets that will be destroyed
4949 // This prevents recursive AutoPacket destructor calls
5050 std::vector<std::shared_ptr<AutoPacket>> packets;
51-
51+
5252 // Recurse through unique successors, storing them in our vector
5353 for (AutoPacket* current = this ; current->m_successor .unique ();) {
5454 packets.push_back (current->m_successor );
55-
55+
5656 // Reset and continue to next successor
5757 AutoPacket* prev_current = current;
5858 current = current->m_successor .get ();
@@ -249,14 +249,14 @@ void AutoPacket::MarkUnsatisfiable(const DecorationKey& key) {
249249
250250void AutoPacket::MarkSuccessorsUnsatisfiable (DecorationKey key) {
251251 std::lock_guard<std::mutex> lk (m_lock);
252-
252+
253253 // Update key and successor
254254 key.tshift ++;
255255 auto successor = SuccessorUnsafe ();
256-
256+
257257 while (m_decoration_map.count (key)) {
258258 successor->MarkUnsatisfiable (key);
259-
259+
260260 // Update key and successor
261261 key.tshift ++;
262262 successor = successor->Successor ();
@@ -661,12 +661,16 @@ bool AutoPacket::Wait(std::condition_variable& cv, const AutoFilterArgument* inp
661661 SignalStub* stub = (SignalStub*)pObj;
662662
663663 // Completed, mark the output as satisfied and update the condition variable
664- std::lock_guard<std::mutex>(stub->packet .m_lock );
665- stub->is_satisfied = true ;
664+ std::condition_variable* pcv;
665+ {
666+ std::lock_guard<std::mutex>{stub->packet .m_lock };
667+ stub->is_satisfied = true ;
668+ pcv = stub->cv ;
669+ }
666670
667671 // Only notify while the condition variable is still valid
668- if (stub-> cv )
669- stub-> cv ->notify_all ();
672+ if (pcv )
673+ pcv ->notify_all ();
670674 }
671675 )
672676 )
@@ -676,12 +680,16 @@ bool AutoPacket::Wait(std::condition_variable& cv, const AutoFilterArgument* inp
676680 // decorations. In that case, the satisfaction flag is left in its initial state
677681 AddTeardownListener (
678682 [stub] {
679- std::lock_guard<std::mutex>(stub->packet .m_lock );
680- stub->is_complete = true ;
683+ std::condition_variable* pcv;
684+ {
685+ std::lock_guard<std::mutex> lk (stub->packet .m_lock );
686+ stub->is_complete = true ;
687+ pcv = stub->cv ;
688+ }
681689
682690 // Only notify the condition variable if it's still present
683- if (stub-> cv )
684- stub-> cv ->notify_all ();
691+ if (pcv )
692+ pcv ->notify_all ();
685693 }
686694 );
687695
0 commit comments