1996-03-19 02:02:52 +00:00
|
|
|
|
/* Interface for NSRunLoop for GNUStep
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
1996-04-17 20:17:45 +00:00
|
|
|
|
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
1996-03-19 02:02:52 +00:00
|
|
|
|
Created: March 1996
|
|
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
|
This file is part of the GNUstep Base Library.
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1996-03-19 02:02:52 +00:00
|
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1996-03-19 02:02:52 +00:00
|
|
|
|
License along with this library; if not, write to the Free
|
2006-03-07 09:14:37 +00:00
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02111 USA.
|
1996-03-19 02:02:52 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
|
#ifndef __NSRunLoop_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
#define __NSRunLoop_h_GNUSTEP_BASE_INCLUDE
|
2006-10-31 07:05:46 +00:00
|
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
|
#import <Foundation/NSMapTable.h>
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@class NSTimer, NSDate, NSPort;
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
2004-07-29 15:30:47 +00:00
|
|
|
|
/**
|
|
|
|
|
* Run loop mode used to deal with input sources other than NSConnections or
|
|
|
|
|
* dialog windows. Most commonly used. Defined in
|
|
|
|
|
* <code>Foundation/NSRunLoop.h</code>.
|
|
|
|
|
*/
|
2002-06-06 14:02:59 +00:00
|
|
|
|
GS_EXPORT NSString * const NSDefaultRunLoopMode;
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
2009-01-12 18:36:37 +00:00
|
|
|
|
@interface NSRunLoop : NSObject
|
1997-09-01 21:59:51 +00:00
|
|
|
|
{
|
2010-02-14 10:48:10 +00:00
|
|
|
|
#if GS_EXPOSE(NSRunLoop)
|
1999-04-19 14:29:52 +00:00
|
|
|
|
@private
|
2002-01-30 15:28:50 +00:00
|
|
|
|
NSString *_currentMode;
|
|
|
|
|
NSMapTable *_contextMap;
|
|
|
|
|
NSMutableArray *_contextStack;
|
|
|
|
|
NSMutableArray *_timedPerformers;
|
|
|
|
|
void *_extra;
|
2010-02-14 10:48:10 +00:00
|
|
|
|
#endif
|
1997-09-01 21:59:51 +00:00
|
|
|
|
}
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
|
|
+ (NSRunLoop*) currentRunLoop;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
- (void) acceptInputForMode: (NSString*)mode
|
2001-12-17 14:31:42 +00:00
|
|
|
|
beforeDate: (NSDate*)limit_date;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
- (void) addTimer: (NSTimer*)timer
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
|
1996-03-19 02:02:52 +00:00
|
|
|
|
- (NSString*) currentMode;
|
|
|
|
|
|
2002-01-30 15:28:50 +00:00
|
|
|
|
- (NSDate*) limitDateForMode: (NSString*)mode;
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
|
|
- (void) run;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
- (BOOL) runMode: (NSString*)mode
|
|
|
|
|
beforeDate: (NSDate*)date;
|
|
|
|
|
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (void) runUntilDate: (NSDate*)date;
|
1996-03-19 02:02:52 +00:00
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@interface NSRunLoop(OPENSTEP)
|
|
|
|
|
|
|
|
|
|
- (void) addPort: (NSPort*)port
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
|
2002-08-27 14:24:54 +00:00
|
|
|
|
- (void) cancelPerformSelectorsWithTarget: (id)target;
|
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
- (void) cancelPerformSelector: (SEL)aSelector
|
2002-01-30 15:28:50 +00:00
|
|
|
|
target: (id)target
|
|
|
|
|
argument: (id)argument;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
|
|
|
|
|
- (void) configureAsServer;
|
|
|
|
|
|
|
|
|
|
- (void) performSelector: (SEL)aSelector
|
2002-01-30 15:28:50 +00:00
|
|
|
|
target: (id)target
|
|
|
|
|
argument: (id)argument
|
2009-02-23 20:42:32 +00:00
|
|
|
|
order: (NSUInteger)order
|
1997-09-01 21:59:51 +00:00
|
|
|
|
modes: (NSArray*)modes;
|
|
|
|
|
|
|
|
|
|
- (void) removePort: (NSPort*)port
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
|
|
|
|
|
@end
|
1996-04-10 18:21:12 +00:00
|
|
|
|
|
1997-09-01 21:59:51 +00:00
|
|
|
|
/*
|
2006-03-07 09:14:37 +00:00
|
|
|
|
* 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.
|
2004-07-29 15:30:47 +00:00
|
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
|
typedef enum {
|
2010-03-19 12:10:11 +00:00
|
|
|
|
#ifdef __MINGW__
|
2005-10-30 10:42:42 +00:00
|
|
|
|
ET_HANDLE, /* Watch for an I/O event on a handle. */
|
|
|
|
|
ET_RPORT, /* Watch for message arriving on port. */
|
|
|
|
|
ET_WINMSG, /* Watch for a message on a window handle. */
|
2006-03-21 15:33:05 +00:00
|
|
|
|
ET_TRIGGER /* Trigger immediately when the loop runs. */
|
2005-02-23 16:05:09 +00:00
|
|
|
|
#else
|
2002-01-30 15:28:50 +00:00
|
|
|
|
ET_RDESC, /* Watch for descriptor becoming readable. */
|
|
|
|
|
ET_WDESC, /* Watch for descriptor becoming writeable. */
|
2005-03-07 01:11:38 +00:00
|
|
|
|
ET_RPORT, /* Watch for message arriving on port. */
|
2006-03-07 09:14:37 +00:00
|
|
|
|
ET_EDESC, /* Watch for descriptor with out-of-band data. */
|
2006-03-21 15:33:05 +00:00
|
|
|
|
ET_TRIGGER /* Trigger immediately when the loop runs. */
|
2005-03-07 01:11:38 +00:00
|
|
|
|
#endif
|
1997-09-01 21:59:51 +00:00
|
|
|
|
} RunLoopEventType;
|
|
|
|
|
@protocol RunLoopEvents
|
2009-06-19 20:19:55 +00:00
|
|
|
|
/* This is the message sent back to a watcher when an event is observed
|
|
|
|
|
* by the run loop.
|
|
|
|
|
* The 'data', 'type' and 'mode' arguments are the same as the arguments
|
|
|
|
|
* passed to the -addEvent:type:watcher:forMode: method.
|
|
|
|
|
* The 'extra' argument varies. For an ET_TRIGGER event, it is the same
|
|
|
|
|
* as the 'data' argument. For other events on unix it is the file
|
|
|
|
|
* descriptor associated with the event (which may be the same as the
|
|
|
|
|
* 'data' argument, but is not in the case of ET_RPORT).
|
|
|
|
|
* For windows it will be the handle or the windows message assciated
|
|
|
|
|
* with the event.
|
|
|
|
|
*/
|
1997-09-01 21:59:51 +00:00
|
|
|
|
- (void) receivedEvent: (void*)data
|
|
|
|
|
type: (RunLoopEventType)type
|
|
|
|
|
extra: (void*)extra
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
@end
|
2008-04-17 07:53:46 +00:00
|
|
|
|
@interface NSObject (RunLoopEvents)
|
|
|
|
|
- (BOOL) runLoopShouldBlock: (BOOL*)shouldTrigger;
|
|
|
|
|
@end
|
2006-03-21 15:33:05 +00:00
|
|
|
|
@class NSStream;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@interface NSRunLoop(GNUstepExtensions)
|
|
|
|
|
- (void) addEvent: (void*)data
|
|
|
|
|
type: (RunLoopEventType)type
|
|
|
|
|
watcher: (id<RunLoopEvents>)watcher
|
|
|
|
|
forMode: (NSString*)mode;
|
|
|
|
|
- (void) removeEvent: (void*)data
|
|
|
|
|
type: (RunLoopEventType)type
|
1997-09-09 15:30:24 +00:00
|
|
|
|
forMode: (NSString*)mode
|
|
|
|
|
all: (BOOL)removeAll;
|
1997-09-01 21:59:51 +00:00
|
|
|
|
@end
|
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
|
#endif /*__NSRunLoop_h_GNUSTEP_BASE_INCLUDE */
|