diff options
-rw-r--r-- | src/lane.cpp | 7 | ||||
-rw-r--r-- | src/lane.hpp | 3 | ||||
-rw-r--r-- | src/universe.hpp | 3 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/lane.cpp b/src/lane.cpp index 4caebcb..2bc3431 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
@@ -633,6 +633,8 @@ void Lane::selfdestructAdd() | |||
633 | assert(selfdestruct_next == nullptr); | 633 | assert(selfdestruct_next == nullptr); |
634 | 634 | ||
635 | selfdestruct_next = U->selfdestructFirst; | 635 | selfdestruct_next = U->selfdestructFirst; |
636 | assert(selfdestruct_next); | ||
637 | |||
636 | U->selfdestructFirst = this; | 638 | U->selfdestructFirst = this; |
637 | } | 639 | } |
638 | 640 | ||
@@ -648,7 +650,7 @@ void Lane::selfdestructAdd() | |||
648 | // cancel/kill). | 650 | // cancel/kill). |
649 | // | 651 | // |
650 | if (selfdestruct_next != nullptr) { | 652 | if (selfdestruct_next != nullptr) { |
651 | Lane* volatile* _ref = static_cast<Lane* volatile*>(&U->selfdestructFirst); | 653 | Lane** _ref{ &U->selfdestructFirst }; |
652 | 654 | ||
653 | while (*_ref != SELFDESTRUCT_END) { | 655 | while (*_ref != SELFDESTRUCT_END) { |
654 | if (*_ref == this) { | 656 | if (*_ref == this) { |
@@ -659,7 +661,7 @@ void Lane::selfdestructAdd() | |||
659 | _found = true; | 661 | _found = true; |
660 | break; | 662 | break; |
661 | } | 663 | } |
662 | _ref = static_cast<Lane* volatile*>(&((*_ref)->selfdestruct_next)); | 664 | _ref = &((*_ref)->selfdestruct_next); |
663 | } | 665 | } |
664 | assert(_found); | 666 | assert(_found); |
665 | } | 667 | } |
@@ -846,7 +848,6 @@ static LUAG_FUNC(lane_gc) | |||
846 | if (_lane->status.load(std::memory_order_acquire) < Lane::Done) { | 848 | if (_lane->status.load(std::memory_order_acquire) < Lane::Done) { |
847 | // still running: will have to be cleaned up later | 849 | // still running: will have to be cleaned up later |
848 | _lane->selfdestructAdd(); | 850 | _lane->selfdestructAdd(); |
849 | assert(_lane->selfdestruct_next); | ||
850 | if (_have_gc_cb) { | 851 | if (_have_gc_cb) { |
851 | luaG_pushstring(L_, "selfdestruct"); // L_: ud gc_cb name status | 852 | luaG_pushstring(L_, "selfdestruct"); // L_: ud gc_cb name status |
852 | lua_call(L_, 2, 0); // L_: ud | 853 | lua_call(L_, 2, 0); // L_: ud |
diff --git a/src/lane.hpp b/src/lane.hpp index 1926824..4f87e2a 100644 --- a/src/lane.hpp +++ b/src/lane.hpp | |||
@@ -128,7 +128,8 @@ class Lane | |||
128 | // M: sets to false, flags true for cancel request | 128 | // M: sets to false, flags true for cancel request |
129 | // S: reads to see if cancel is requested | 129 | // S: reads to see if cancel is requested |
130 | 130 | ||
131 | Lane* volatile selfdestruct_next{ nullptr }; | 131 | // access is protected by Universe::selfDestructMutex |
132 | Lane* selfdestruct_next{ nullptr }; | ||
132 | // | 133 | // |
133 | // M: sets to non-nullptr if facing lane handle '__gc' cycle but the lane | 134 | // M: sets to non-nullptr if facing lane handle '__gc' cycle but the lane |
134 | // is still running | 135 | // is still running |
diff --git a/src/universe.hpp b/src/universe.hpp index 18e125f..a45ce86 100644 --- a/src/universe.hpp +++ b/src/universe.hpp | |||
@@ -113,7 +113,8 @@ class Universe | |||
113 | std::atomic<int> debugspewIndentDepth{ 0 }; | 113 | std::atomic<int> debugspewIndentDepth{ 0 }; |
114 | #endif // USE_DEBUG_SPEW() | 114 | #endif // USE_DEBUG_SPEW() |
115 | 115 | ||
116 | Lane* volatile selfdestructFirst{ nullptr }; | 116 | // access is protected by selfDestructMutex |
117 | Lane* selfdestructFirst{ nullptr }; | ||
117 | // After a lane has removed itself from the chain, it still performs some processing. | 118 | // After a lane has removed itself from the chain, it still performs some processing. |
118 | // The terminal desinit sequence should wait for all such processing to terminate before force-killing threads | 119 | // The terminal desinit sequence should wait for all such processing to terminate before force-killing threads |
119 | std::atomic<int> selfdestructingCount{ 0 }; | 120 | std::atomic<int> selfdestructingCount{ 0 }; |