Added files accidentally missed from last check in

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20787 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-02-23 21:43:18 +00:00
parent 2a9f4ec7c0
commit 37eda7e2db
2 changed files with 145 additions and 0 deletions

View file

@ -0,0 +1,69 @@
#ifndef __GSRunLoopCtxt_h_GNUSTEP_BASE_INCLUDE
#define __GSRunLoopCtxt_h_GNUSTEP_BASE_INCLUDE
#include "config.h"
#include <Foundation/NSException.h>
#include <Foundation/NSMapTable.h>
#include <Foundation/NSRunLoop.h>
/*
* Setup for inline operation of arrays.
*/
#define GSI_ARRAY_TYPES GSUNION_OBJ
#if GS_WITH_GC == 0
#define GSI_ARRAY_RELEASE(A, X) [(X).obj release]
#define GSI_ARRAY_RETAIN(A, X) [(X).obj retain]
#else
#define GSI_ARRAY_RELEASE(A, X)
#define GSI_ARRAY_RETAIN(A, X)
#endif
#include "GNUstepBase/GSIArray.h"
#ifdef HAVE_POLL
typedef struct{
int limit;
short *index;
}pollextra;
#endif
@class NSString;
@interface GSRunLoopCtxt : NSObject
{
@public
void *extra; /** Copy of the RunLoop ivar. */
NSString *mode; /** The mode for this context. */
GSIArray performers; /** The actions to perform regularly. */
GSIArray timers; /** The timers set for the runloop mode */
GSIArray watchers; /** The inputs set for the runloop mode */
#ifdef __MINGW32__
id msgTarget; /** Target to raise a win32 message */
SEL msgSelector; /** method of target */
#endif
@private
#ifdef __MINGW32__
NSMapTable *handleMap;
#else
NSMapTable *_efdMap;
NSMapTable *_rfdMap;
NSMapTable *_wfdMap;
int fairStart; // For trying to ensure fair handling.
#endif
BOOL completed; // To mark operation as completed.
#ifdef HAVE_POLL
unsigned int pollfds_capacity;
unsigned int pollfds_count;
struct pollfd *pollfds;
#endif
}
- (void) endEvent: (void*)data
type: (RunLoopEventType)type;
- (void) endPoll;
- (id) initWithMode: (NSString*)theMode extra: (void*)e;
- (BOOL) pollUntil: (int)milliseconds within: (NSArray*)contexts;
@end
#endif /* __GSRunLoopCtxt_h_GNUSTEP_BASE_INCLUDE */

View file

@ -0,0 +1,76 @@
#ifndef __GSRunLoopWatcher_h_GNUSTEP_BASE_INCLUDE
#define __GSRunLoopWatcher_h_GNUSTEP_BASE_INCLUDE
/*
* The 'GSRunLoopWatcher' class was written to permit the (relatively)
* easy addition of new events to be watched for in the runloop.
*
* To add a new type of event, the 'RunLoopEventType' enumeration must be
* extended, and the methods must be modified to handle the new type.
*
* The internal variables if the GSRunLoopWatcher are used as follows -
*
* The '_date' variable contains a date after which the event is useless
* and the watcher can be removed from the runloop.
*
* If '_invalidated' is set, the watcher should be disabled and should
* be removed from the runloop when next encountered.
*
* The 'data' variable is used to identify the resource/event that the
* watcher is interested in.
*
* The 'receiver' is the object which should be told when the event
* occurs. This object is retained so that we know it will continue
* to exist and can handle a callback.
*
* The 'type' variable indentifies the type of event watched for.
* NSRunLoops [-acceptInputForMode: beforeDate: ] method MUST contain
* code to watch for events of each type.
*
* To set this variable, the method adding the GSRunLoopWatcher to the
* runloop must ask the 'receiver' (or its delegate) to supply a date
* using the '[-limitDateForMode: ]' message.
*
* NB. This class is private to NSRunLoop and must not be subclassed.
*/
#include "config.h"
#include "GNUstepBase/preface.h"
#include <Foundation/NSRunLoop.h>
@class NSDate;
extern SEL eventSel; /* Initialized in [NSRunLoop +initialize] */
@interface GSRunLoopWatcher: NSObject
{
@public
NSDate *_date; /* First to match layout of NSTimer */
BOOL _invalidated; /* 2nd to match layout of NSTimer */
IMP handleEvent; /* New-style event handling */
void *data;
id receiver;
RunLoopEventType type;
unsigned count;
}
- (id) initWithType: (RunLoopEventType)type
receiver: (id)anObj
data: (void*)data;
@end
/*
* Two optimisation functions that depend on a hack that the layout of
* the NSTimer class is known to be the same as GSRunLoopWatcher for the
* first two elements.
*/
static inline NSDate* timerDate(NSTimer* timer)
{
return ((GSRunLoopWatcher*)timer)->_date;
}
static inline BOOL timerInvalidated(NSTimer* timer)
{
return ((GSRunLoopWatcher*)timer)->_invalidated;
}
#endif /* __GSRunLoopWatcher_h_GNUSTEP_BASE_INCLUDE */