Re: [AD] rest and yield_timeslice

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


On Mon, 2004-07-19 at 08:30 -0700, Chris wrote:
> Elias Pschernig wrote:
> > No. select does just what we want (same as usleep, but usleep is
> > deprecated according to my docs).
> 
> According to my man pages, select is 4.4BSD. nanosleep is 
> POSIX.1b(formerly POSIX.4). Pas that it's a crude hack, using a function 
> for something it wasn't designed for. That in and of itself isnt't a big 
> deal.. but when we have a fully POSIX-compliant alternative?
> 
> And from what I've heard, select is fully dependable, either.
> 

Using select() seems a standard way to sleep in unix, to me.

> > Good point. I copied the code from timer.c actually - so that would need
> > changing as well then, at least for unix. (Or do djgpp/mingw have
> > gettimeofday?)
> 
> IIRC, MinGW does have gettimeofday, and I think I used it in DJGPP once. 
> I can't say how accurate it is there though (I would doubt any worse 
> than 10ms).
> 
> > Yes, I'm proposing it with my mail. If there are complaints against it,
> > we can keep long. I see no point in having a signed variable though.
> 
> Apologies. I thought you said you were going to be commiting it. 
> However, in my experience you don't really need to use the signed or 
> unsigned keywords unless you a) need the increased max, or b) can't 
> handle negative numbers. And calling rest(0x80000000u) will effectively 
> rest you for several days or weeks.. I doubt we need that. And we can 
> deal with negatives just fine (time <= 0 instead of !time). Plus, rest 
> has always been non-unsigned, so you'd need a good reason to change it, IMO.
> 

Well, I'd have committed it if there wasn't complaints of course :) The
reason why I want to change to unsigned is, negative values make no
sense. Designing an API so there is little room for errorneous
parameters (<0 in the case of rest) always seems to be a good idea.
Making <0 a documented valid value for rest seem to be a worse
alternative, as does just leaving it as undefined bahavior.

And in this case, there is not even a backwards compatibility problem,
other than possible warnings for passing signed variables, since <0 is
unspeecified in the docs so far.

-- 
Elias Pschernig





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