aboutsummaryrefslogtreecommitdiff
path: root/src/lane.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lane.cpp')
-rw-r--r--src/lane.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lane.cpp b/src/lane.cpp
index c2cbbac..8f31973 100644
--- a/src/lane.cpp
+++ b/src/lane.cpp
@@ -677,7 +677,7 @@ static void lane_main(Lane* const lane_)
677#ifndef __PROSPERO__ 677#ifndef __PROSPERO__
678 lane_->ready.wait(); 678 lane_->ready.wait();
679#else // __PROSPERO__ 679#else // __PROSPERO__
680 while (!lane_->ready._My_flag) { 680 while (!lane_->ready.test()) {
681 std::this_thread::yield(); 681 std::this_thread::yield();
682 } 682 }
683#endif // __PROSPERO__ 683#endif // __PROSPERO__
@@ -719,7 +719,8 @@ static void lane_main(Lane* const lane_)
719 lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release); 719 lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release);
720 lane_->U->selfdestructMutex.unlock(); 720 lane_->U->selfdestructMutex.unlock();
721 721
722 // we destroy our jthread member from inside the thread body, so we have to detach so that we don't try to join, as this doesn't seem a good idea 722 // we destroy ourselves, therefore our thread member too, from inside the thread body
723 // detach so that we don't try to join, as this doesn't seem a good idea
723 lane_->thread.detach(); 724 lane_->thread.detach();
724 delete lane_; 725 delete lane_;
725 return; 726 return;
@@ -828,6 +829,11 @@ Lane::Lane(Universe* U_, lua_State* L_, ErrorTraceLevel errorTraceLevel_)
828 829
829Lane::~Lane() 830Lane::~Lane()
830{ 831{
832 // not necessary when using a jthread
833 if (thread.joinable()) {
834 thread.join();
835 }
836 // no longer tracked
831 std::ignore = U->tracker.tracking_remove(this); 837 std::ignore = U->tracker.tracking_remove(this);
832} 838}
833 839
@@ -1032,9 +1038,9 @@ void Lane::securizeDebugName(lua_State* L_)
1032 1038
1033void Lane::startThread(int priority_) 1039void Lane::startThread(int priority_)
1034{ 1040{
1035 thread = std::jthread([this]() { lane_main(this); }); 1041 thread = std::thread([this]() { lane_main(this); });
1036 if (priority_ != kThreadPrioDefault) { 1042 if (priority_ != kThreadPrioDefault) {
1037 JTHREAD_SET_PRIORITY(thread, priority_, U->sudo); 1043 THREAD_SET_PRIORITY(thread, priority_, U->sudo);
1038 } 1044 }
1039} 1045}
1040 1046