Please help me.
I Try exclusive control.
I want to set a timeout on a semaphore.
However, I am in trouble because I do not know the proper syntax.
Perhaps I expect to use "semaphore.wait (timeout: __)", but I cant do it well
----------
/* create */
static var semaphore = DispatchSemaphore(value: 1)
semaphore.wait()
~~~Perform communication processing~~~
semaphore.signal()
----------
Please show your code using `semaphore.wait (timeout: __)` with relevant parts. `wait(timeout:)` is the right method, so you need to explain what "I cant do it well" means. Compile-time error? Runtime error? Runs without errors but behaves unexpectedly?
---
By the way, generally, you should not call `semaphore.wait()` in the main thread. Are you alright with this?