Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
GameQueueGate.cpp
Go to the documentation of this file.
1#include "GameQueueGate.hpp"
2
4{
6 {
7 count_ = 0;
8 lastActionTick_ = 0;
9 }
10
11 void GameQueueGate::lock(std::uint64_t tick) noexcept
12 {
13 ++count_;
14 lastActionTick_ = tick;
15 }
16
17 void GameQueueGate::unlock(std::uint64_t tick) noexcept
18 {
19 --count_;
20 if (count_ < 0) count_ = 0;
21 lastActionTick_ = tick;
22 }
23
24 bool GameQueueGate::blocks(std::uint64_t tick) noexcept
25 {
26 if (count_ <= 0) return false;
27 if (tick > lastActionTick_ &&
28 tick - lastActionTick_ > MaxLockTicks)
29 {
30 // The source clears the count then calls gameQueueUnLock(),
31 // whose clamp leaves the final count at zero.
32 count_ = 0;
33 lastActionTick_ = tick;
34 return false;
35 }
36 return true;
37 }
38}
unsigned index
void lock(std::uint64_t tick) noexcept
bool blocks(std::uint64_t tick) noexcept
void unlock(std::uint64_t tick) noexcept