Function Semaphore.setCapacity
Change the capacity of the semaphore
void setCapacity
(
ulong newCapacity,
bool immediate = false
) @nogc @safe;
If immediate
is set to false
and the current level
is higher than the requested capacity, setCapacity
will sleep until the capacity can be cleared.
If immediate
is false
then setCapacity
may return before the new capacity is actually set. This will
only happen if there is an older setCapacity
call that has not yet finished.
Parameters
Name | Description |
---|---|
newCapacity | The new capacity |
immediate | whether the new capacity takes effect immediately. |
Warnings
Setting the capacity to lower than the number of resources a waiting fiber is currently requesting is undefined.
If immediate
is set to true
, it is possible for level
to report a higher acquired count than capacity
.
If there is a chance that multiple calls to setCapacity
are active at once, the immeditate
flag must be set
the same way on all of them. In other words, it is illegal to call setCapacity
with immediate
set to false
,
and then call setCapacity
with immediate
set to true before the first call returns.