diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-11-13 10:00:20 +0100 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-11-13 10:00:20 +0100 |
commit | 43915511f5e0c74a5aa6e0d02fe62505eb133191 (patch) | |
tree | b4e4e06a85e8d8868c0d551ebce74f9900606020 /src/linda.cpp | |
parent | d9879337c9843d7bcc936a6fbf0755288ed70607 (diff) | |
download | lanes-43915511f5e0c74a5aa6e0d02fe62505eb133191.tar.gz lanes-43915511f5e0c74a5aa6e0d02fe62505eb133191.tar.bz2 lanes-43915511f5e0c74a5aa6e0d02fe62505eb133191.zip |
Cleaning up guano
Converted volatile Lane::status to std::atomic
Diffstat (limited to 'src/linda.cpp')
-rw-r--r-- | src/linda.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/linda.cpp b/src/linda.cpp index 9658e38..80f62d3 100644 --- a/src/linda.cpp +++ b/src/linda.cpp | |||
@@ -671,9 +671,9 @@ LUAG_FUNC(linda_receive) | |||
671 | Lane::Status _prev_status{ Lane::Error }; // prevent 'might be used uninitialized' warnings | 671 | Lane::Status _prev_status{ Lane::Error }; // prevent 'might be used uninitialized' warnings |
672 | if (_lane != nullptr) { | 672 | if (_lane != nullptr) { |
673 | // change status of lane to "waiting" | 673 | // change status of lane to "waiting" |
674 | _prev_status = _lane->status; // Running, most likely | 674 | _prev_status = _lane->status.load(std::memory_order_acquire); // Running, most likely |
675 | LUA_ASSERT(L_, _prev_status == Lane::Running); // but check, just in case | 675 | LUA_ASSERT(L_, _prev_status == Lane::Running); // but check, just in case |
676 | _lane->status = Lane::Waiting; | 676 | _lane->status.store(Lane::Waiting, std::memory_order_release); |
677 | LUA_ASSERT(L_, _lane->waiting_on == nullptr); | 677 | LUA_ASSERT(L_, _lane->waiting_on == nullptr); |
678 | _lane->waiting_on = &_linda->writeHappened; | 678 | _lane->waiting_on = &_linda->writeHappened; |
679 | } | 679 | } |
@@ -684,7 +684,7 @@ LUAG_FUNC(linda_receive) | |||
684 | _try_again = (_status == std::cv_status::no_timeout); // detect spurious wakeups | 684 | _try_again = (_status == std::cv_status::no_timeout); // detect spurious wakeups |
685 | if (_lane != nullptr) { | 685 | if (_lane != nullptr) { |
686 | _lane->waiting_on = nullptr; | 686 | _lane->waiting_on = nullptr; |
687 | _lane->status = _prev_status; | 687 | _lane->status.store(_prev_status, std::memory_order_release); |
688 | } | 688 | } |
689 | } | 689 | } |
690 | } | 690 | } |
@@ -816,9 +816,9 @@ LUAG_FUNC(linda_send) | |||
816 | Lane::Status _prev_status{ Lane::Error }; // prevent 'might be used uninitialized' warnings | 816 | Lane::Status _prev_status{ Lane::Error }; // prevent 'might be used uninitialized' warnings |
817 | if (_lane != nullptr) { | 817 | if (_lane != nullptr) { |
818 | // change status of lane to "waiting" | 818 | // change status of lane to "waiting" |
819 | _prev_status = _lane->status; // Running, most likely | 819 | _prev_status = _lane->status.load(std::memory_order_acquire); // Running, most likely |
820 | LUA_ASSERT(L_, _prev_status == Lane::Running); // but check, just in case | 820 | LUA_ASSERT(L_, _prev_status == Lane::Running); // but check, just in case |
821 | _lane->status = Lane::Waiting; | 821 | _lane->status.store(Lane::Waiting, std::memory_order_release); |
822 | LUA_ASSERT(L_, _lane->waiting_on == nullptr); | 822 | LUA_ASSERT(L_, _lane->waiting_on == nullptr); |
823 | _lane->waiting_on = &_linda->readHappened; | 823 | _lane->waiting_on = &_linda->readHappened; |
824 | } | 824 | } |
@@ -829,7 +829,7 @@ LUAG_FUNC(linda_send) | |||
829 | _try_again = (status == std::cv_status::no_timeout); // detect spurious wakeups | 829 | _try_again = (status == std::cv_status::no_timeout); // detect spurious wakeups |
830 | if (_lane != nullptr) { | 830 | if (_lane != nullptr) { |
831 | _lane->waiting_on = nullptr; | 831 | _lane->waiting_on = nullptr; |
832 | _lane->status = _prev_status; | 832 | _lane->status.store(_prev_status, std::memory_order_release); |
833 | } | 833 | } |
834 | } | 834 | } |
835 | } | 835 | } |