aboutsummaryrefslogtreecommitdiff
path: root/src/linda.cpp
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-11-13 11:05:32 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2024-11-13 11:05:32 +0100
commit2f2f29391012949385631e5bee7c35fed71392dd (patch)
tree382a2bbaa7dcbf5bda3ca322626d29d539f6f738 /src/linda.cpp
parentf2a3c033fc31332e78aa45d2d9deaf51359b584a (diff)
downloadlanes-2f2f29391012949385631e5bee7c35fed71392dd.tar.gz
lanes-2f2f29391012949385631e5bee7c35fed71392dd.tar.bz2
lanes-2f2f29391012949385631e5bee7c35fed71392dd.zip
Cleaning up guano
* Lane::waiting on does not need to be volatile or anything else, all accesses are controlled through status acquire/release semantics * this contains fixes about bad ordering of said accesses in Linda:send and Linda:receive
Diffstat (limited to 'src/linda.cpp')
-rw-r--r--src/linda.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/linda.cpp b/src/linda.cpp
index 1536da5..99d0cbe 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -673,9 +673,9 @@ LUAG_FUNC(linda_receive)
673 // change status of lane to "waiting" 673 // change status of lane to "waiting"
674 _prev_status = _lane->status.load(std::memory_order_acquire); // 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.store(Lane::Waiting, std::memory_order_release);
677 LUA_ASSERT(L_, _lane->waiting_on == nullptr); 676 LUA_ASSERT(L_, _lane->waiting_on == nullptr);
678 _lane->waiting_on = &_linda->writeHappened; 677 _lane->waiting_on = &_linda->writeHappened;
678 _lane->status.store(Lane::Waiting, std::memory_order_release);
679 } 679 }
680 // not enough data to read: wakeup when data was sent, or when timeout is reached 680 // not enough data to read: wakeup when data was sent, or when timeout is reached
681 std::unique_lock<std::mutex> _guard{ _keeper->mutex, std::adopt_lock }; 681 std::unique_lock<std::mutex> _guard{ _keeper->mutex, std::adopt_lock };
@@ -818,9 +818,9 @@ LUAG_FUNC(linda_send)
818 // change status of lane to "waiting" 818 // change status of lane to "waiting"
819 _prev_status = _lane->status.load(std::memory_order_acquire); // 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.store(Lane::Waiting, std::memory_order_release);
822 LUA_ASSERT(L_, _lane->waiting_on == nullptr); 821 LUA_ASSERT(L_, _lane->waiting_on == nullptr);
823 _lane->waiting_on = &_linda->readHappened; 822 _lane->waiting_on = &_linda->readHappened;
823 _lane->status.store(Lane::Waiting, std::memory_order_release);
824 } 824 }
825 // could not send because no room: wait until some data was read before trying again, or until timeout is reached 825 // could not send because no room: wait until some data was read before trying again, or until timeout is reached
826 std::unique_lock<std::mutex> _guard{ _keeper->mutex, std::adopt_lock }; 826 std::unique_lock<std::mutex> _guard{ _keeper->mutex, std::adopt_lock };