Re: [AD] replace xlock/xunlock with synchronized{}

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


On Thu, 2006-04-06 at 10:38 +0200, Evert Glebbeek wrote:
> > #define synchronized for( int __l( ! XLOCK() ); __l; __l = 0, XUNLOCK() ) )
> 
> This is a no-go because you cannot do this pre C99.

Another gcc specific version might be:

#define synchronized auto void tempfunc(void); lock(); tempfunc(); unlock(); void tempfunc(void)

That doesn't have the problem of missing the unlock on return, but has
other problems..

> >Unfortunately there is the risk of incorrect but seemingly correct code
> >like this:
> >
> >    synchronized {
> > if (foo) {
> >     return 1;
> > }
> >    }
> 
> Indeed. I don't think it's a good idea then.
> On the whole, I would try to stear clear of syntactic sugar like this, that 
> tries to mimic new control structures, neat as they may look.
> 

I agree. About the XLOCK/XUNLOCK, we probably should try and see if in
4.3 and with X.org, we can use XInitThreads instead.

-- 
Elias Pschernig





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