diff options
Diffstat (limited to 'src/linda.cpp')
-rw-r--r-- | src/linda.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/linda.cpp b/src/linda.cpp index 82f5f98..cda3a63 100644 --- a/src/linda.cpp +++ b/src/linda.cpp | |||
@@ -133,7 +133,7 @@ static void check_key_types(lua_State* L_, int start_, int end_) | |||
133 | static constexpr std::array<std::reference_wrapper<UniqueKey const>, 3> kKeysToCheck{ kLindaBatched, kCancelError, kNilSentinel }; | 133 | static constexpr std::array<std::reference_wrapper<UniqueKey const>, 3> kKeysToCheck{ kLindaBatched, kCancelError, kNilSentinel }; |
134 | for (UniqueKey const& key : kKeysToCheck) { | 134 | for (UniqueKey const& key : kKeysToCheck) { |
135 | if (key.equals(L_, i)) { | 135 | if (key.equals(L_, i)) { |
136 | raise_luaL_error(L_, "argument #%d: can't use %s as a key", i, key.m_debugName); | 136 | raise_luaL_error(L_, "argument #%d: can't use %s as a key", i, key.debugName); |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | } | 139 | } |
@@ -276,20 +276,20 @@ LUAG_FUNC(linda_send) | |||
276 | Lane::Status prev_status{ Lane::Error }; // prevent 'might be used uninitialized' warnings | 276 | Lane::Status prev_status{ Lane::Error }; // prevent 'might be used uninitialized' warnings |
277 | if (lane != nullptr) { | 277 | if (lane != nullptr) { |
278 | // change status of lane to "waiting" | 278 | // change status of lane to "waiting" |
279 | prev_status = lane->m_status; // Running, most likely | 279 | prev_status = lane->status; // Running, most likely |
280 | LUA_ASSERT(L_, prev_status == Lane::Running); // but check, just in case | 280 | LUA_ASSERT(L_, prev_status == Lane::Running); // but check, just in case |
281 | lane->m_status = Lane::Waiting; | 281 | lane->status = Lane::Waiting; |
282 | LUA_ASSERT(L_, lane->m_waiting_on == nullptr); | 282 | LUA_ASSERT(L_, lane->waiting_on == nullptr); |
283 | lane->m_waiting_on = &linda->m_read_happened; | 283 | lane->waiting_on = &linda->m_read_happened; |
284 | } | 284 | } |
285 | // could not send because no room: wait until some data was read before trying again, or until timeout is reached | 285 | // could not send because no room: wait until some data was read before trying again, or until timeout is reached |
286 | std::unique_lock<std::mutex> keeper_lock{ K->m_mutex, std::adopt_lock }; | 286 | std::unique_lock<std::mutex> keeper_lock{ K->m_mutex, std::adopt_lock }; |
287 | std::cv_status const status{ linda->m_read_happened.wait_until(keeper_lock, until) }; | 287 | std::cv_status const status{ linda->m_read_happened.wait_until(keeper_lock, until) }; |
288 | keeper_lock.release(); // we don't want to release the lock! | 288 | keeper_lock.release(); // we don't want to release the lock! |
289 | try_again = (status == std::cv_status::no_timeout); // detect spurious wakeups | 289 | try_again = (status == std::cv_status::no_timeout); // detect spurious wakeups |
290 | if (lane != nullptr) { | 290 | if (lane != nullptr) { |
291 | lane->m_waiting_on = nullptr; | 291 | lane->waiting_on = nullptr; |
292 | lane->m_status = prev_status; | 292 | lane->status = prev_status; |
293 | } | 293 | } |
294 | } | 294 | } |
295 | } | 295 | } |
@@ -423,11 +423,11 @@ LUAG_FUNC(linda_receive) | |||
423 | Lane::Status prev_status{ Lane::Error }; // prevent 'might be used uninitialized' warnings | 423 | Lane::Status prev_status{ Lane::Error }; // prevent 'might be used uninitialized' warnings |
424 | if (lane != nullptr) { | 424 | if (lane != nullptr) { |
425 | // change status of lane to "waiting" | 425 | // change status of lane to "waiting" |
426 | prev_status = lane->m_status; // Running, most likely | 426 | prev_status = lane->status; // Running, most likely |
427 | LUA_ASSERT(L_, prev_status == Lane::Running); // but check, just in case | 427 | LUA_ASSERT(L_, prev_status == Lane::Running); // but check, just in case |
428 | lane->m_status = Lane::Waiting; | 428 | lane->status = Lane::Waiting; |
429 | LUA_ASSERT(L_, lane->m_waiting_on == nullptr); | 429 | LUA_ASSERT(L_, lane->waiting_on == nullptr); |
430 | lane->m_waiting_on = &linda->m_write_happened; | 430 | lane->waiting_on = &linda->m_write_happened; |
431 | } | 431 | } |
432 | // not enough data to read: wakeup when data was sent, or when timeout is reached | 432 | // not enough data to read: wakeup when data was sent, or when timeout is reached |
433 | std::unique_lock<std::mutex> keeper_lock{ K->m_mutex, std::adopt_lock }; | 433 | std::unique_lock<std::mutex> keeper_lock{ K->m_mutex, std::adopt_lock }; |
@@ -435,8 +435,8 @@ LUAG_FUNC(linda_receive) | |||
435 | keeper_lock.release(); // we don't want to release the lock! | 435 | keeper_lock.release(); // we don't want to release the lock! |
436 | try_again = (status == std::cv_status::no_timeout); // detect spurious wakeups | 436 | try_again = (status == std::cv_status::no_timeout); // detect spurious wakeups |
437 | if (lane != nullptr) { | 437 | if (lane != nullptr) { |
438 | lane->m_waiting_on = nullptr; | 438 | lane->waiting_on = nullptr; |
439 | lane->m_status = prev_status; | 439 | lane->status = prev_status; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | } | 442 | } |