During the DispatchSemaphore function, Is it OK to call Signal() first and Wait() later? If call Signal() N continuously, does the value internally become N, Or I wonder if invoking Signal() several times does not increase the value when Wait() is not called.
let sempahore = DispatchSemaphore(value: 0)
semaphore.signal()
semaphore.signal()
semaphore.signal()
// in time, what is sempahore value? 1 or 3?
sempahore.wait()
// in time, what is semaphore value? 0 or 2?
// wait for more signal? or not?
Every
.signal
is '+1', and every.wait
is '-1' orblock
as documented, and code that demo isHere is from Apple Documentation