Re: [AD] Allegro OS X code |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Michael Benfield wrote:
I'm still not really familiar with Allegro's internals yet and I don't
know Cocoa but in connection with trying to get rid of main mangling
I'm trying to understand this... any help would be appreciated.
Allegro's OS X stuff starts a new thread for the user's code, and the
main thread ends up in a while (1) loop, repeatedly calling stuff like
osx_event_handler(). Is this the right way to do it? It really seems
like that stuff should be called every iteration through the Allegro
user's main loop, rather than concurrent with that loop.
I don't know Cocoa, but if it is anything like X windows (and IIRC
Windows also) then the event handler really does need to run in a
separate thread. That is due to Allegro's API. Allegro doesn't have a
message pump function that we can force users to keep calling in order
to keep everything working. And the poll_* functions are not much good,
because (i) nobody uses them, and (ii) they are only supposed to handle
one thing each, yet in real OSes the event handler gets _all_ the
various messages.
An additional catch in Cocoa's case was that only the main thread is
allowed to handle events, or something like that. Hence the user's
code has to go into another thread.
The mailing list archive should have plenty of info. I remember Angelo
comparing the situation with SDL which does have a message pump. We
also discussed a poll_system() function or something.
Peter