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

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 15 March 2002 18:47 pm, Eric Botcazou wrote:
> Hence I propose al_lock_mutex()/al_unlock_mutex().

Hmm, I know Peter said verb/noun, but this is different to pthreads, 
and I at least will always get this the wrong way round if that is the 
case! (Just to prove the point to myself, I did it wrong below when 
typing this mail ;-) ).

> - should we use a BITMAP-style API: [snip]

How about both allowing dynamic and static allocation:

AL_MUTEX
  This is the mutex type. You can create one with al_create_mutex(), in 
which case you must destroy it with al_destroy_mutex(), or you can 
statically initialise one with AL_MUTEX_INITIALISER. Allegro mutexes 
are not recursive.

AL_MUTEX_INITIALISER
  A macro used for initialising a mutex variable, eg:
AL_MUTEX mutex = AL_MUTEX_INITIALISER;

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).

void al_destroy_mutex(AL_MUTEX*)
  Frees any resources associated with a mutex. Should only be called on 
mutexes obtained with al_create_mutex(). Don't use the mutex after 
destroying it.

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. [These functions could fail in some rather ridiculous 
circumstances; we could reflect this with a return value?]

Bye for now,
- -- 
Laurence Withers, lwithers@xxxxxxxxxx
                 http://www.lwithers.demon.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8kk+nZutPpDHGwY0RApLgAJ9fi2WDmaI9B5MPIFSVr+0CvCXiygCfWKaS
PvPW2OLfyGnHty6eMSAKAMA=
=RRzk
-----END PGP SIGNATURE-----



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