[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: about RunLoop, joystick support and so on

From: Richard Frith-Macdonald
Subject: Re: about RunLoop, joystick support and so on
Date: Fri, 9 Feb 2007 05:34:34 +0000

On 8 Feb 2007, at 11:06, Xavier Glattard wrote:

Hi all

I try to understand NSRunLoop and event management.

I have found the following text in NSRunLoop.h
It's about GSRunLoopWatcher

 * The following interface is not yet deprecated,
 * but may be deprecated in the next release and
 * removed thereafter.
 * The run loop watcher API was originally intended to perform two
 * tasks ...
 * 1. provide the most efficient API reasonably possible to integrate
 * unix networking code into the runloop.
 * 2. provide a standard mechanism to allow people to contribute
* code to add new I/O mechanisms to GNUstep (OpenStep didn't allow this).
 * It succeeded in 1, and partially succeeded in 2 (adding support
 * for the win32 API).
* However, several years on, CPU's are even faster with respect to I/O * and the performance issue is less significant, and Apple have provided * the NSStream API which allows yoiu to write stream subclasses and add
 * them to the run loop.
* We are likely to follow Apple for compatibility, and restructure code
 * using NSStream, at which point this API will be redundant.

What is the status of GSRunLoopWatcher ?

Current, as described in the text you quote which warns that Apple appear to be close to providing a general API for the task (even though it's not clear yet) and we will probably adopt it.

Why is it not use in backend ?

It is used in the backend ... see back/Source/win32/WIN32Server.m which handles the received events.

(under win32, PeekMessage/DispatchMessage are called firth by the DisplayServer
then by GSRunLoopCtxt)

If you look carefully at the GSRunLoopCtxt code, you will see that DispatchMessage is called only for unhandled messages (ie those not passed on to a GSRunLoopWatcher). I don't know why the -callback: method is also called ... I would have thought that it was unnecessary, but perhaps it's a performance tweak. ie, after receiving an event via the runloop mechanism the code then removes any other events from the windows queue directly. Maybe someone else can better answer this.

Is there an other mechanism on the way ?

Not yet.

If i want to add joystick support to GNUstep, which interface do i
have to use ?

I think that depends on how the operating system presents the joystick interface. If it appears as a file from which you read data, then it's probably best to open that file as an NSInputStream and use that API, otherwise using GSRunLoopWatcher is the way to go. You can look at the code of the NSStream subclasses to see how then use GSRunLoopWatcher internally.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]