Add timeout versions for LightLock, RecursiveLock, and LightSemaphore
I'm curious as to which use case prompted this PR.
Some questions:
I have a slightly different implementation a while back: source
It doesn't yet have decreasing timeout on looped arbitrate attempts, which I tried to remedy in this version (from branch)
There are some other differences though:
- I used
ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUTinstead ofARBITRATION_WAIT_IF_LESS_THAN, not sure if it matters. - On timeout or error, for LightLock, the waiting thread count is released by 1 before returning: source, I don't see similar code in your PR.
- Similarly for LightSemaphore, the number of threads acquiring the lock is released by 1 before returning: source. Again In your PR the status is returned before doing the associated adjustment.
So the question:
Are those adjustment unnecessary (or incorrect) in my version? I do use the code in a homebrew and it works afaict..
@fincs
As for use case, I just wanted something that matches the behavior of svcWaitSynchronization as I have macro to switch between either svc sync or libctru sync for testing purpose.