diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2025-04-28 11:17:48 +0200 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2025-04-28 11:17:48 +0200 |
| commit | a86327245eea5638b933aec795026699201c19e1 (patch) | |
| tree | f8d03b6abc1d0d215dd38852d1c018e8b4e84f62 /src/lane.cpp | |
| parent | d93a433732c5ca72923100f5ab8139a8a5f072b6 (diff) | |
| download | lanes-a86327245eea5638b933aec795026699201c19e1.tar.gz lanes-a86327245eea5638b933aec795026699201c19e1.tar.bz2 lanes-a86327245eea5638b933aec795026699201c19e1.zip | |
Minor internal tweaks in shutdown code
Diffstat (limited to 'src/lane.cpp')
| -rw-r--r-- | src/lane.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lane.cpp b/src/lane.cpp index 5cebdfa..e6ea2e5 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
| @@ -783,10 +783,14 @@ static void lane_main(Lane* const lane_) | |||
| 783 | if (lane_->selfdestructRemove()) { // check and remove (under lock!) | 783 | if (lane_->selfdestructRemove()) { // check and remove (under lock!) |
| 784 | // We're a free-running thread and no-one is there to clean us up. | 784 | // We're a free-running thread and no-one is there to clean us up. |
| 785 | lane_->closeState(); | 785 | lane_->closeState(); |
| 786 | lane_->U->selfdestructMutex.lock(); | 786 | |
| 787 | // done with lua_close(), terminal shutdown sequence may proceed | 787 | // let's try not to crash if the lane didn't terminate gracefully and the Universe met its end |
| 788 | lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release); | 788 | if (!lane_->flaggedAfterUniverseGC.load(std::memory_order_relaxed)) { |
| 789 | lane_->U->selfdestructMutex.unlock(); | 789 | lane_->U->selfdestructMutex.lock(); |
| 790 | // done with lua_close(), terminal shutdown sequence may proceed | ||
| 791 | lane_->U->selfdestructingCount.fetch_sub(1, std::memory_order_release); | ||
| 792 | lane_->U->selfdestructMutex.unlock(); | ||
| 793 | } | ||
| 790 | 794 | ||
| 791 | // we destroy ourselves, therefore our thread member too, from inside the thread body | 795 | // we destroy ourselves, therefore our thread member too, from inside the thread body |
| 792 | // detach so that we don't try to join, as this doesn't seem a good idea | 796 | // detach so that we don't try to join, as this doesn't seem a good idea |
