Open ZeroStride opened 14 years ago
There are four different backends for semaphores:
WaitForSingleObject
as you proposedsem_trywait
as you proposedpthread_cond_timedwait
.dispatch_semaphore_wait
can be used.This is doable and definitly needed.
Proposal:
int amp_semaphore_trywait(amp_semaphore_t*)
Invokes: Windows:
WaitForSingleObject(HANDLE, 0);
pthreads:sem_trywait(sem_t*);
Notes: Windows uses
WaitForSingleObject
to perform the functionality ofsem_trywait
as well assem_timedwait
however the MacOS implementation of pthreads does not contain asem_timedwait
. It does supportpthread_cond_timedwait
, however. For this reason I am not proposing an implementation oftimedwait
.References: http://msdn.microsoft.com/en-us/library/ms687032(v=VS.85).aspx?ppud=4 http://developer.apple.com/macosx/multithreadedprogramming.html