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

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


On March 25, 2002 10:22 am, you wrote:
> > void handler(void)
> > {
> >   al_mutex_lock(my_mutex);
> >   my_value = 0;
> >   al_mutex_unlock(my_mutex);
> > }
> >
> > int main()
> > {
> >   al_mutex_lock(my_mutex);
> >   /* handler called here */
> >   if(my_value) do something;
> >   al_mutex_unlock(my_mutex);
> >
> >   ...
> > }
> >
> > if mutexes do nothing then wouldn't that be a bit odd? how would that be
> > handled? (can't wait in the handler...)
>
> That's indeed annoying. This mutex API was primarily intended to make the
> callback functions atomic when pthread timers are used, like when signal
> timers are used. However, the thread/mutex mechanism is symmetrical with
> regard to the main flow of control and the callbacks, whereas the single
> process/signal mechanism is not.
>
> Solution (a) would lead to clearly state this dissymmetry in the docs, but
> that would sound a bit technical.

Or as Laurence pointed out there could be a al_mutex_trylock().. maybe.

-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx
http://strangesoft.net



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