[Kernel] ReleaseSemaphore for Posix to match Windows semantics
This commit is contained in:
@@ -320,14 +320,15 @@ class PosixCondition<Semaphore> final : public PosixConditionBase {
|
||||
bool Signal() override { return Release(1, nullptr); }
|
||||
|
||||
bool Release(uint32_t release_count, int* out_previous_count) {
|
||||
if (maximum_count_ - count_ >= release_count) {
|
||||
auto lock = std::unique_lock(mutex_);
|
||||
if (out_previous_count) *out_previous_count = count_;
|
||||
count_ += release_count;
|
||||
cond_.notify_all();
|
||||
return true;
|
||||
auto lock = std::unique_lock(mutex_);
|
||||
// Validate that releasing would not exceed the maximum count
|
||||
if (count_ + release_count > maximum_count_) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
if (out_previous_count) *out_previous_count = count_;
|
||||
count_ += release_count;
|
||||
cond_.notify_all();
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user