2005-02-23 21:43:18 +00:00
|
|
|
#ifndef __GSRunLoopCtxt_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __GSRunLoopCtxt_h_GNUSTEP_BASE_INCLUDE
|
2009-02-26 11:09:05 +00:00
|
|
|
/**
|
|
|
|
Copyright (C) 2008-2009 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
By: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
|
|
|
|
|
|
|
$Date$ $Revision$
|
|
|
|
*/
|
2005-02-23 21:43:18 +00:00
|
|
|
|
2012-03-01 09:14:08 +00:00
|
|
|
#import "common.h"
|
|
|
|
#import "Foundation/NSException.h"
|
|
|
|
#import "Foundation/NSMapTable.h"
|
|
|
|
#import "Foundation/NSRunLoop.h"
|
2005-02-23 21:43:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup for inline operation of arrays.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define GSI_ARRAY_TYPES GSUNION_OBJ
|
|
|
|
|
|
|
|
#define GSI_ARRAY_RELEASE(A, X) [(X).obj release]
|
|
|
|
#define GSI_ARRAY_RETAIN(A, X) [(X).obj retain]
|
|
|
|
|
|
|
|
#include "GNUstepBase/GSIArray.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_POLL
|
|
|
|
typedef struct{
|
|
|
|
int limit;
|
|
|
|
short *index;
|
|
|
|
}pollextra;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
@class NSString;
|
2006-03-24 10:59:00 +00:00
|
|
|
@class GSRunLoopWatcher;
|
2005-02-23 21:43:18 +00:00
|
|
|
|
|
|
|
@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. */
|
2009-09-07 09:53:27 +00:00
|
|
|
unsigned maxPerformers;
|
2005-02-23 21:43:18 +00:00
|
|
|
GSIArray timers; /** The timers set for the runloop mode */
|
2009-09-07 09:53:27 +00:00
|
|
|
unsigned maxTimers;
|
2005-02-23 21:43:18 +00:00
|
|
|
GSIArray watchers; /** The inputs set for the runloop mode */
|
2009-09-07 09:53:27 +00:00
|
|
|
unsigned maxWatchers;
|
2005-02-23 21:43:18 +00:00
|
|
|
@private
|
2016-03-09 13:16:16 +00:00
|
|
|
#if defined(_WIN32)
|
2005-02-23 21:43:18 +00:00
|
|
|
NSMapTable *handleMap;
|
2005-10-30 10:42:42 +00:00
|
|
|
NSMapTable *winMsgMap;
|
2005-02-23 21:43:18 +00:00
|
|
|
#else
|
|
|
|
NSMapTable *_efdMap;
|
|
|
|
NSMapTable *_rfdMap;
|
|
|
|
NSMapTable *_wfdMap;
|
|
|
|
#endif
|
2006-03-21 15:33:05 +00:00
|
|
|
GSIArray _trigger; // Watchers to trigger unconditionally.
|
|
|
|
int fairStart; // For trying to ensure fair handling.
|
2005-02-23 21:43:18 +00:00
|
|
|
BOOL completed; // To mark operation as completed.
|
|
|
|
#ifdef HAVE_POLL
|
|
|
|
unsigned int pollfds_capacity;
|
|
|
|
unsigned int pollfds_count;
|
|
|
|
struct pollfd *pollfds;
|
|
|
|
#endif
|
|
|
|
}
|
2009-01-15 15:06:04 +00:00
|
|
|
/* Check to see of the thread has been awakened, blocking until it
|
|
|
|
* does get awakened or until the limit date has been reached.
|
2016-07-16 08:25:24 +00:00
|
|
|
* A date in the past (or nil) results in a check followed by an
|
2009-01-15 15:06:04 +00:00
|
|
|
* immediate return.
|
|
|
|
*/
|
|
|
|
+ (BOOL) awakenedBefore: (NSDate*)when;
|
2005-02-23 21:43:18 +00:00
|
|
|
- (void) endEvent: (void*)data
|
2006-03-24 10:59:00 +00:00
|
|
|
for: (GSRunLoopWatcher*)watcher;
|
2005-02-23 21:43:18 +00:00
|
|
|
- (void) endPoll;
|
|
|
|
- (id) initWithMode: (NSString*)theMode extra: (void*)e;
|
|
|
|
- (BOOL) pollUntil: (int)milliseconds within: (NSArray*)contexts;
|
|
|
|
@end
|
|
|
|
|
|
|
|
#endif /* __GSRunLoopCtxt_h_GNUSTEP_BASE_INCLUDE */
|