mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 08:40:44 +00:00
Various tweaks.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@12123 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0e2bd154dc
commit
22cb892946
4 changed files with 468 additions and 411 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2002-01-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSRunLoop.m: Wrap code in exception handlers to reset current
|
||||
runloop mode if an exception occurs ... may remove this again if the
|
||||
performance is too bad.
|
||||
Use initialiser for NSTimer to avoid having to put timers into the
|
||||
autorelease pool.
|
||||
* Headers/Foundation/NSTimer.h: Expose GNUstep initialiser since
|
||||
OpenStep and MacOS-X don't have one.
|
||||
|
||||
Wed Jan 16 13:46:24 2002 Nicola Pero <nicola@brainstorm.co.uk>
|
||||
|
||||
Fixed dynamical loading of frameworks.
|
||||
|
|
|
@ -51,18 +51,18 @@
|
|||
invocation: (NSInvocation*)invocation
|
||||
repeats: (BOOL)f;
|
||||
+ (NSTimer*) scheduledTimerWithTimeInterval: (NSTimeInterval)ti
|
||||
target: object
|
||||
target: (id)object
|
||||
selector: (SEL)selector
|
||||
userInfo: info
|
||||
userInfo: (id)info
|
||||
repeats: (BOOL)f;
|
||||
|
||||
+ (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti
|
||||
invocation: (NSInvocation*)invocation
|
||||
repeats: (BOOL)f;
|
||||
+ (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti
|
||||
target: object
|
||||
target: (id)object
|
||||
selector: (SEL)selector
|
||||
userInfo: info
|
||||
userInfo: (id)info
|
||||
repeats: (BOOL)f;
|
||||
|
||||
- (void) fire;
|
||||
|
@ -76,6 +76,13 @@
|
|||
- (NSDate*) fireDate;
|
||||
- (id) userInfo;
|
||||
|
||||
#ifndef NO_GNUSTEP
|
||||
- (id) initWithTimeInterval: (NSTimeInterval)ti
|
||||
targetOrInvocation: (id)object
|
||||
selector: (SEL)selector
|
||||
userInfo: (id)info
|
||||
repeats: (BOOL)f;
|
||||
#endif
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
|
@ -268,6 +268,7 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
|
|||
- (void) dealloc
|
||||
{
|
||||
[self gcFinalize];
|
||||
TEST_RELEASE(timer);
|
||||
RELEASE(target);
|
||||
RELEASE(argument);
|
||||
[super dealloc];
|
||||
|
@ -275,7 +276,7 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
|
|||
|
||||
- (void) fire
|
||||
{
|
||||
timer = nil;
|
||||
DESTROY(timer);
|
||||
[target performSelector: selector withObject: argument];
|
||||
[[[NSRunLoop currentRunLoop] _timedPerformers]
|
||||
removeObjectIdenticalTo: self];
|
||||
|
@ -284,7 +285,9 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
|
|||
- (void) gcFinalize
|
||||
{
|
||||
if (timer != nil)
|
||||
{
|
||||
[timer invalidate];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithSelector: (SEL)aSelector
|
||||
|
@ -293,13 +296,14 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
|
|||
delay: (NSTimeInterval)delay
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
if (self != nil)
|
||||
{
|
||||
selector = aSelector;
|
||||
target = RETAIN(aTarget);
|
||||
argument = RETAIN(anArgument);
|
||||
timer = [NSTimer timerWithTimeInterval: delay
|
||||
target: self
|
||||
timer = [[NSTimer allocWithZone: NSDefaultMallocZone()]
|
||||
initWithTimeInterval: delay
|
||||
targetOrInvocation: self
|
||||
selector: @selector(fire)
|
||||
userInfo: nil
|
||||
repeats: NO];
|
||||
|
@ -830,7 +834,9 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
/* This is the designated initializer. */
|
||||
- (id) init
|
||||
{
|
||||
[super init];
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_mode_2_timers = NSCreateMapTable (NSNonRetainedObjectMapKeyCallBacks,
|
||||
ArrayMapValueCallBacks, 0);
|
||||
_mode_2_watchers = NSCreateMapTable (NSObjectMapKeyCallBacks,
|
||||
|
@ -844,6 +850,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
WatcherMapValueCallBacks, 0);
|
||||
_wfdMap = NSCreateMapTable (NSIntMapKeyCallBacks,
|
||||
WatcherMapValueCallBacks, 0);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -894,9 +901,10 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
}
|
||||
|
||||
|
||||
/* Fire appropriate timers and determine the earliest time that anything
|
||||
watched for becomes useless. */
|
||||
|
||||
/**
|
||||
* Fire appropriate timers and determine the earliest time that anything
|
||||
* watched for becomes useless.
|
||||
*/
|
||||
- (NSDate*) limitDateForMode: (NSString*)mode
|
||||
{
|
||||
id saved_mode;
|
||||
|
@ -910,6 +918,8 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
saved_mode = _current_mode;
|
||||
_current_mode = mode;
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
timers = NSMapGet(_mode_2_timers, mode);
|
||||
if (timers)
|
||||
{
|
||||
|
@ -1018,8 +1028,15 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
_current_mode = saved_mode;
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
_current_mode = saved_mode;
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
RELEASE(arp);
|
||||
|
||||
/*
|
||||
|
@ -1087,6 +1104,8 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
}
|
||||
_current_mode = mode;
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
/* Find out how much time we should wait, and set SELECT_TIMEOUT. */
|
||||
if (!limit_date)
|
||||
{
|
||||
|
@ -1100,7 +1119,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
{
|
||||
/* Wait until the LIMIT_DATE. */
|
||||
if (debug_run_loop)
|
||||
printf ("\tNSRunLoop accept input before %f (seconds from now %f)\n",
|
||||
printf ("\tNSRunLoop accept input before %f (sec from now %f)\n",
|
||||
[limit_date timeIntervalSinceReferenceDate], ti);
|
||||
/* If LIMIT_DATE has already past, return immediately. */
|
||||
timeout.tv_sec = ti;
|
||||
|
@ -1209,18 +1228,25 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
int port_fd_count = 128; // xxx #define this constant
|
||||
int port_fd_array[port_fd_count];
|
||||
|
||||
if ([port respondsToSelector: @selector(getFds:count:)])
|
||||
[port getFds: port_fd_array count: &port_fd_count];
|
||||
if ([port respondsToSelector:
|
||||
@selector(getFds:count:)])
|
||||
{
|
||||
[port getFds: port_fd_array
|
||||
count: &port_fd_count];
|
||||
}
|
||||
if (debug_run_loop)
|
||||
{
|
||||
printf("\tNSRunLoop listening to %d sockets\n",
|
||||
port_fd_count);
|
||||
|
||||
}
|
||||
while (port_fd_count--)
|
||||
{
|
||||
fd = port_fd_array[port_fd_count];
|
||||
FD_SET (port_fd_array[port_fd_count], &read_fds);
|
||||
if (fd > end_inputs)
|
||||
{
|
||||
end_inputs = fd;
|
||||
}
|
||||
NSMapInsert(_rfdMap,
|
||||
(void*)port_fd_array[port_fd_count], info);
|
||||
num_inputs++;
|
||||
|
@ -1234,24 +1260,29 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
end_inputs++;
|
||||
|
||||
/*
|
||||
* If there are notifications in the 'idle' queue, we try an instantaneous
|
||||
* select so that, if there is no input pending, we can service the queue.
|
||||
* Similarly, if a task has completed, we need to deliver it's notifications.
|
||||
* If there are notifications in the 'idle' queue, we try an
|
||||
* instantaneous select so that, if there is no input pending,
|
||||
* we can service the queue. Similarly, if a task has completed,
|
||||
* we need to deliver it's notifications.
|
||||
*/
|
||||
if (GSCheckTasks() || GSNotifyMore())
|
||||
{
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
select_timeout = &timeout;
|
||||
select_return = select (end_inputs, &read_fds, &write_fds, &exception_fds,
|
||||
select_timeout);
|
||||
select_return = select (end_inputs, &read_fds, &write_fds,
|
||||
&exception_fds, select_timeout);
|
||||
}
|
||||
else
|
||||
select_return = select (end_inputs, &read_fds, &write_fds, &exception_fds,
|
||||
select_timeout);
|
||||
{
|
||||
select_return = select (end_inputs, &read_fds, &write_fds,
|
||||
&exception_fds, select_timeout);
|
||||
}
|
||||
|
||||
if (debug_run_loop)
|
||||
{
|
||||
printf ("\tNSRunLoop select returned %d\n", select_return);
|
||||
}
|
||||
|
||||
if (select_return < 0)
|
||||
{
|
||||
|
@ -1260,13 +1291,13 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
GSCheckTasks();
|
||||
select_return = 0;
|
||||
}
|
||||
#ifdef __MINGW__
|
||||
#ifdef __MINGW__
|
||||
else if (errno == 0)
|
||||
{
|
||||
/* MinGW often returns an errno == 0. Not sure why */
|
||||
select_return = 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
else
|
||||
{
|
||||
/* Some exceptional condition happened. */
|
||||
|
@ -1381,7 +1412,6 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
}
|
||||
while (fdIndex != fdEnd);
|
||||
|
||||
|
||||
/* Clean up before returning. */
|
||||
NSResetMapTable(_efdMap);
|
||||
NSResetMapTable(_rfdMap);
|
||||
|
@ -1390,6 +1420,13 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
|||
[self _checkPerformers];
|
||||
GSNotifyASAP();
|
||||
_current_mode = saved_mode;
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
_current_mode = saved_mode;
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
RELEASE(arp);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,10 @@ static Class NSDate_class;
|
|||
}
|
||||
}
|
||||
|
||||
/* This is the designated initializer. */
|
||||
/*
|
||||
* <init />
|
||||
* Initialise a newly allocated NSTimer object.
|
||||
*/
|
||||
- (id) initWithTimeInterval: (NSTimeInterval)seconds
|
||||
targetOrInvocation: (id)t
|
||||
selector: (SEL)sel
|
||||
|
|
Loading…
Reference in a new issue