Re: [AD] Mini-synchronization API proposal for 4.1.x

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2002-03-15, Laurence Withers <lwithers@xxxxxxxxxx> wrote:
> AL_MUTEX_INITIALISER
>   A macro used for initialising a mutex variable, eg:
> AL_MUTEX mutex = AL_MUTEX_INITIALISER;

Wait for the complaints about the spelling ;-)  Otherwise, it's
probably a good idea and not hard to support both methods.

> AL_MUTEX* al_create_mutex(void)
>   Creates a new mutex object, which should be destroyed with 
> al_destroy_mutex(). Returns 0 on error (out of memory).

Allegro says "NULL" usually, and it shouldn't say "out of memory"
explicitly (maybe the OS limits the number of mutexes per thread, or
whatever).

> void al_lock_mutex(AL_MUTEX*)
> void al_unlock_mutex(AL_MUTEX*)
>   Locks/unlocks a mutex. Note that Allegro mutexes are not recursive, 
> so if you lock the same mutex twice within a thread, you will cause a 
> deadlock.

Is it easy to implement non-recursive behaviour in Win32?  If not,
consider:

  Note that Allegro mutexes are not necessarily recursive.  The
behaviour of locking the same mutex twice within a thread is
unspecified.

> [These functions could fail in some rather ridiculous 
> circumstances; we could reflect this with a return value?]

Like unlocking an unlocked mutex?


All in all, it looks good.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/