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

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


On 2002-03-28, Peter Wang <tjaden@xxxxxxxxxx> wrote:
> On 2002-03-27, Eric Botcazou <ebotcazou@xxxxxxxxxx> wrote:
> > How do you ensure atomicity for the callbacks ? Do you require that a
> > al_system_lock()/al_system_unlock() pair be placed inside the user callback
> > function too:
[snip]
> > or does any callback automatically lock the system lock ?
> 
> Not sure.  Both methods have their merits.  I think it depends if
> locking is expensive.  If it is, then it should be the user's choice.

Wait.. that'd mean we'd be right back where we started.  So the system
must automatically lock.

Anyway, attached is a very trashy prototype for Linux + X11 + timer
callbacks.  It works with both pthreads and SIGALRM.  What happens is
that if callbacks are disabled, any new callback 'events' are added to
the queue, which is completely flushed when callbacks are reenabled. I
don't know if that's good (what if the flushing takes too long?), but
it was easy to code :-)

To convince yourself it's actually working, comment out the
al_{disable,enable}_callbacks lines in the modified extimer.c.
Without them, the program will quit almost instantly, with both
SIGALRM and pthreads.

Attachment: disablecallbacks-1.diff.gz
Description: application/gunzip



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