If another resource is available, acquire it and return true. Else return false.
| 80 | // If another resource is available, acquire it and return true. |
| 81 | // Else return false. |
| 82 | bool Acquire() { |
| 83 | int old_acquires_allowed = |
| 84 | acquires_allowed_.fetch_sub(1, std::memory_order_relaxed); |
| 85 | |
| 86 | if (old_acquires_allowed > 0) return true; |
| 87 | |
| 88 | acquires_allowed_.fetch_add(1, std::memory_order_relaxed); |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | // Release a resource acquired by a previous call to Acquire() that returned |
| 93 | // true. |
no outgoing calls
no test coverage detected