aboutsummaryrefslogtreecommitdiff
path: root/src/lane.cpp
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-11-13 10:41:01 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2024-11-13 10:41:01 +0100
commit9e8930f02e7a53a41b713c642bcb53b3b61f7cb5 (patch)
tree60251c62749d5a3ab1e9c5f088ecf362a56cb192 /src/lane.cpp
parentf45a3f5de2a11065764c87208d3f0b58e6ebe771 (diff)
downloadlanes-9e8930f02e7a53a41b713c642bcb53b3b61f7cb5.tar.gz
lanes-9e8930f02e7a53a41b713c642bcb53b3b61f7cb5.tar.bz2
lanes-9e8930f02e7a53a41b713c642bcb53b3b61f7cb5.zip
Cleaning up guano
Lane::selfdestruct_next and Universe::selfdestructFirst do not need to be volatile or anything else, all accesses are mutex-protected
Diffstat (limited to 'src/lane.cpp')
-rw-r--r--src/lane.cpp7
1 files changed, 4 insertions, 3 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