| 68 | |
| 69 | template<ptrdiff_t LeastMaxValue> |
| 70 | void CountingSemaphoreRP<LeastMaxValue>::release(ptrdiff_t update) { |
| 71 | FL_ASSERT(update >= 0, "CountingSemaphoreRP: release update must be non-negative"); |
| 72 | FL_ASSERT(mSpinlock != nullptr, "CountingSemaphoreRP::release() called on null semaphore"); |
| 73 | |
| 74 | spin_lock_t* spinlock = static_cast<spin_lock_t*>(mSpinlock); |
| 75 | |
| 76 | // Acquire spinlock to protect count manipulation |
| 77 | u32 save = spin_lock_blocking(spinlock); |
| 78 | |
| 79 | // Check if we would exceed max value |
| 80 | if (mCount + update > mMaxValue) { |
| 81 | spin_unlock(spinlock, save); |
| 82 | FL_ASSERT(false, "CountingSemaphoreRP: release would exceed max value"); |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | mCount += update; |
| 87 | |
| 88 | // Release spinlock |
| 89 | spin_unlock(spinlock, save); |
| 90 | } |
| 91 | |
| 92 | template<ptrdiff_t LeastMaxValue> |
| 93 | void CountingSemaphoreRP<LeastMaxValue>::acquire() { |
no outgoing calls
no test coverage detected