Sleeping better for lower latencies (and other things)

I agree that having something like select() would be more useful.

Me too, but that’s one of the trickiest part, because the equivalent
APIs are rather different from one platform to the other.

Here’s a PyGame snippet that does this (only on x11):

Of note that this is more or less what my demo program at the top of
this thread does, but that there is some problem with it and switching
to fullscreen, where SDL seems to rely on SDL_PollEvent() to be called
when there is nothing to do, at certain (more or less random) times. I
find this particular bit of code rather strange, my Xlib code that
does switching to/from fullscreen didn’t need any of this and seems to
work fine?

Maybe some esoteric bit of knowledge about mysterious behaviour of
some X11 servers that I don’t know? Somebody knows?

Also, I think removing SDL_PushEvent() would solve a lot of
problems… including simplifying event blocking when it is
implemented. It doesn’t make sense to use an outside library to manage
a game’s event queue to me…

I think it’s mostly used for communicating to the main thread from
other threads. I’m not that offended by the concept, but in my own
programs, I tend to reuse timers in that case, simply adding a timer
for now. I use a pipe set in non-blocking mode to wake up the
select() from other threads when signals come in (there’s a classic
race conditional regarding select() and signal handling, again
XtAppAddSignal deals with that) or when timers are added (so that we
"notice" them if they’re from another thread). Just write one byte,
ignore any error, and remember to read all the bytes from the pipe
after returning from select()! See
http://pphaneuf.livejournal.com/158971.html, and maybe
http://pphaneuf.livejournal.com/158346.html too (although SDL’s need
in this matter are probably much simpler).On Thu, May 15, 2008 at 7:59 PM, Forrest Voight wrote:


http://pphaneuf.livejournal.com/

The problem with high-end games is that they’re usually coded at least
half-way properly

Funniest thing I’ve read all day. :stuck_out_tongue:

–ryan.

I was just trying to be polite. Sheesh!

KHMan wrote:> Edward Cullen wrote:

Hi,

Must confess, I’m not in a position to comment on the detail of what
you’ve written; I was simply trying to give you what I know as an
overview…

I think you’ll need to take this up with Sam and/or Ryan directly, as
they’re MUCH more familiar with the internals and design decisions with
regard to various platforms than I probably ever will :).

Sam is normally very open to ideas (especially those accompanied by
sample implementations…), but he has also spent a very long time
refining SDL, so don’t be surprised if he has ‘answers for everything’.
It may be that some original assumptions no longer apply - SDL started
back in 1998ish… :smiley:

Eddy, you don’t have to reply to every query that goes by. A
mailing list allows the community to share expertise, and
sometimes it’s better to wait a while for other, possibly more
comprehensive or expert replies, before jumping in. Some restraint
is sometimes better, and it’s not necessary to be a spokesperson
for Sam or Ryan. Less noise will give higher quality conversations.

Eddy

Pierre Phaneuf wrote:

On Fri, May 9, 2008 at 5:01 AM, Eddy Cullen wrote:
[snip]

HTH,