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

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


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

--
Eric Botcazou
ebotcazou@xxxxxxxxxx



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