Threads and events

Ok, sorry, one more question …

I would like to poll events in a separate thread. SDL is not designed to do
this. However last time I tried it stuff got in a mess because
it actually DOES work with X11.

I’m not sure about OSX but I think it will probably work on OSX too,
or at least can be made to (at least recent versions).

From memory again: on Windows, each thread has its own event queue.
However, one thread can read another threads event queue.

So it seems possible to organise it on at least the three major desktop
platforms to have event polling in a separate thread. I would like that,
because I have special technology for interfacing asynchronous events
with synchronous code.

is anyone else interested in investigating this?
[I only have access to OSX at the moment]–
john skaller
@john_skaller
http://felix-lang.org

The problem is that on Windows events need to be handled in the thread
where the window was created (it won’t work properly in any other
thread, even if you take measures to prevent two threads from doing it
at the same time). This is not a limitation of SDL, it’s a limitation
of the Windows API itself. No idea about other platforms (X is fairly
forgiving in that sense, though).

What you can do with SDL right now is get the window thread to poll
for events (i.e. fill the queue) and then read the queue from a
different thread. That trick has been mentioned several times in the
mailing list before.

You could also create the window in its own thread and use that as a
wrapper, but it’s far from trivial (it can be a pain to maintain) and
I don’t know about the performance implications.

2013/6/10, john skaller :> Ok, sorry, one more question …

I would like to poll events in a separate thread. SDL is not designed to do
this. However last time I tried it stuff got in a mess because
it actually DOES work with X11.

I’m not sure about OSX but I think it will probably work on OSX too,
or at least can be made to (at least recent versions).

From memory again: on Windows, each thread has its own event queue.
However, one thread can read another threads event queue.

So it seems possible to organise it on at least the three major desktop
platforms to have event polling in a separate thread. I would like that,
because I have special technology for interfacing asynchronous events
with synchronous code.

is anyone else interested in investigating this?
[I only have access to OSX at the moment]


john skaller
skaller at users.sourceforge.net
http://felix-lang.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org