My boss says it is ok to contribute the cross-platform condition variable
code I wrote here. It is currently not very APR like though. It uses
common macros defined in header files with common C code. I can rip out
the implementation easily into unix & win32 files though. beos & mac will
have to be done by someone else. I haven't programmed on a mac in close to
a decade. :)
Where is the best place to put this in APR? It doesn't seem to belong in
apr/locks/ - does it deserve its own subdirectory in APR?
For win32 this uses events:
init -- pcond = CreateEvent(NULL,TRUE,TRUE,NULL);
wait -- HANDLE h[2]; h[0] = pcond; h[1] = mutex;
MUTEX_UNLOCK(mid);
WaitForMultipleObjects(2,h,TRUE,INFINITE);
signal -- SetEvent(pcond);
broadcast -- ResetEvent(pcond);
destroy -- CloseHandle(pcond);
On unix of course we would just use the pthread_cond_xxx routines. The
only sticky point I see is having some way to get the underlying system
representation from an `apr_lock_t' to pass to WaitForMultipleObjects or
pthread_cond_wait.
Would it be sane to include locks.h and do the appropriate munging? Nobody
outside of the locks/ directory seems to use it (other that
misc/unix/start.c and that is just for a forward function declaration).
-bp
--
Ceterum censeo vi esse delendam