[Top][All Lists]

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

Re: nonblocking I/O

From: richard
Subject: Re: nonblocking I/O
Date: Thu, 26 Oct 2000 23:26:47 +0100

On Thu, 26 Oct 2000 23:53:46 +0200, address@hidden wrote:
> Hi,
> in OPENSTEP and MOSX, there is some 'hidden' functionality to allow
> nonblocking I/O using NSFileHandling. On MOSX there exists i.e. a method
> -availableDataNonBlocking, on OPENSTEP there is some old NEXTSTEP 'derived'
> functionality available, not documented but visible from the header (can't
> check it right now, since I do not have access to OPENSTEP anymore).
> Is there something comparable in GNUstep as well, or what might I use to
> implement for example logging of other tasks' stdout using pipes from a
> GNUstep app? -readInBackgroundAndNotify does not do the job, as it seems.

Not sure what you want or why -readInBackgroundAndNotify doesn't do the job.
You probably want
-waitForDataInBackgroundAndNotify (notifies when a handle is readable)
-writeInBackgroundAndNotify: (notifies when a handle is writable)
-initAsClientInBackgroundAtAddress:service:protocol: (socket connect)

GNUstep also provides a lower-level, but more efficient (callback rather
than notification) mechanism for monitoring things in NSRunLoop.
>From NSRunLoop.h -

 *      GNUstep extensions

typedef enum {
    ET_RDESC,   /* Watch for descriptor becoming readable.      */
    ET_WDESC,   /* Watch for descriptor becoming writeable.     */
    ET_RPORT,   /* Watch for message arriving on port.          */
    ET_EDESC   /* Watch for descriptor with exception data.     */
} RunLoopEventType;

@protocol RunLoopEvents
 *      Callback message sent to object waiting for an event in the
 *      runloop when the limit-date for the operation is reached.
 *      If an NSDate object is returned, the operation is restarted
 *      with the new limit-date, otherwise it is removed from the
 *      run loop.
- (NSDate*) timedOutEvent: (void*)data
                     type: (RunLoopEventType)type
                  forMode: (NSString*)mode;
 *      Callback message sent to object when the event it it waiting
 *      for occurs.  The 'data' and 'type' valueds are those passed in the
 *      original addEvent:type:watcher:forMode: method.
 *      The 'extra' value may be additional data returned depending
 *      on the type of event.
- (void) receivedEvent: (void*)data
                  type: (RunLoopEventType)type
                 extra: (void*)extra
               forMode: (NSString*)mode;

 *      These next two are general purpose methods for letting objects
 *      ask the runloop to watch for events for them.  Only one object
 *      at a time may be watching for a particular event in a mode, but
 *      that object may add itsself as a watcher many times as long as
 *      each addition is matched by a removal (the run loop keeps count).
 *      Alternatively, the 'removeAll' parameter may be set to 'YES' for
 *      [-removeEvent:type:forMode:all:] in order to remove the watcher
 *      irrespective of the number of times it has been added.
- (void) addEvent: (void*)data
             type: (RunLoopEventType)type
          watcher: (id<RunLoopEvents>)watcher
          forMode: (NSString*)mode;
- (void) removeEvent: (void*)data
                type: (RunLoopEventType)type
             forMode: (NSString*)mode
                 all: (BOOL)removeAll;

reply via email to

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