mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-12 00:51:08 +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>
|
Wed Jan 16 13:46:24 2002 Nicola Pero <nicola@brainstorm.co.uk>
|
||||||
|
|
||||||
Fixed dynamical loading of frameworks.
|
Fixed dynamical loading of frameworks.
|
||||||
|
|
|
@ -51,18 +51,18 @@
|
||||||
invocation: (NSInvocation*)invocation
|
invocation: (NSInvocation*)invocation
|
||||||
repeats: (BOOL)f;
|
repeats: (BOOL)f;
|
||||||
+ (NSTimer*) scheduledTimerWithTimeInterval: (NSTimeInterval)ti
|
+ (NSTimer*) scheduledTimerWithTimeInterval: (NSTimeInterval)ti
|
||||||
target: object
|
target: (id)object
|
||||||
selector: (SEL)selector
|
selector: (SEL)selector
|
||||||
userInfo: info
|
userInfo: (id)info
|
||||||
repeats: (BOOL)f;
|
repeats: (BOOL)f;
|
||||||
|
|
||||||
+ (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti
|
+ (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti
|
||||||
invocation: (NSInvocation*)invocation
|
invocation: (NSInvocation*)invocation
|
||||||
repeats: (BOOL)f;
|
repeats: (BOOL)f;
|
||||||
+ (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti
|
+ (NSTimer*) timerWithTimeInterval: (NSTimeInterval)ti
|
||||||
target: object
|
target: (id)object
|
||||||
selector: (SEL)selector
|
selector: (SEL)selector
|
||||||
userInfo: info
|
userInfo: (id)info
|
||||||
repeats: (BOOL)f;
|
repeats: (BOOL)f;
|
||||||
|
|
||||||
- (void) fire;
|
- (void) fire;
|
||||||
|
@ -76,6 +76,13 @@
|
||||||
- (NSDate*) fireDate;
|
- (NSDate*) fireDate;
|
||||||
- (id) userInfo;
|
- (id) userInfo;
|
||||||
|
|
||||||
|
#ifndef NO_GNUSTEP
|
||||||
|
- (id) initWithTimeInterval: (NSTimeInterval)ti
|
||||||
|
targetOrInvocation: (id)object
|
||||||
|
selector: (SEL)selector
|
||||||
|
userInfo: (id)info
|
||||||
|
repeats: (BOOL)f;
|
||||||
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -268,6 +268,7 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[self gcFinalize];
|
[self gcFinalize];
|
||||||
|
TEST_RELEASE(timer);
|
||||||
RELEASE(target);
|
RELEASE(target);
|
||||||
RELEASE(argument);
|
RELEASE(argument);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
@ -275,7 +276,7 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
|
||||||
|
|
||||||
- (void) fire
|
- (void) fire
|
||||||
{
|
{
|
||||||
timer = nil;
|
DESTROY(timer);
|
||||||
[target performSelector: selector withObject: argument];
|
[target performSelector: selector withObject: argument];
|
||||||
[[[NSRunLoop currentRunLoop] _timedPerformers]
|
[[[NSRunLoop currentRunLoop] _timedPerformers]
|
||||||
removeObjectIdenticalTo: self];
|
removeObjectIdenticalTo: self];
|
||||||
|
@ -284,8 +285,10 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
|
||||||
- (void) gcFinalize
|
- (void) gcFinalize
|
||||||
{
|
{
|
||||||
if (timer != nil)
|
if (timer != nil)
|
||||||
|
{
|
||||||
[timer invalidate];
|
[timer invalidate];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (id) initWithSelector: (SEL)aSelector
|
- (id) initWithSelector: (SEL)aSelector
|
||||||
target: (id)aTarget
|
target: (id)aTarget
|
||||||
|
@ -293,13 +296,14 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1)
|
||||||
delay: (NSTimeInterval)delay
|
delay: (NSTimeInterval)delay
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self != nil)
|
||||||
{
|
{
|
||||||
selector = aSelector;
|
selector = aSelector;
|
||||||
target = RETAIN(aTarget);
|
target = RETAIN(aTarget);
|
||||||
argument = RETAIN(anArgument);
|
argument = RETAIN(anArgument);
|
||||||
timer = [NSTimer timerWithTimeInterval: delay
|
timer = [[NSTimer allocWithZone: NSDefaultMallocZone()]
|
||||||
target: self
|
initWithTimeInterval: delay
|
||||||
|
targetOrInvocation: self
|
||||||
selector: @selector(fire)
|
selector: @selector(fire)
|
||||||
userInfo: nil
|
userInfo: nil
|
||||||
repeats: NO];
|
repeats: NO];
|
||||||
|
@ -830,7 +834,9 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
/* This is the designated initializer. */
|
/* This is the designated initializer. */
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
[super init];
|
self = [super init];
|
||||||
|
if (self != nil)
|
||||||
|
{
|
||||||
_mode_2_timers = NSCreateMapTable (NSNonRetainedObjectMapKeyCallBacks,
|
_mode_2_timers = NSCreateMapTable (NSNonRetainedObjectMapKeyCallBacks,
|
||||||
ArrayMapValueCallBacks, 0);
|
ArrayMapValueCallBacks, 0);
|
||||||
_mode_2_watchers = NSCreateMapTable (NSObjectMapKeyCallBacks,
|
_mode_2_watchers = NSCreateMapTable (NSObjectMapKeyCallBacks,
|
||||||
|
@ -844,6 +850,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
WatcherMapValueCallBacks, 0);
|
WatcherMapValueCallBacks, 0);
|
||||||
_wfdMap = NSCreateMapTable (NSIntMapKeyCallBacks,
|
_wfdMap = NSCreateMapTable (NSIntMapKeyCallBacks,
|
||||||
WatcherMapValueCallBacks, 0);
|
WatcherMapValueCallBacks, 0);
|
||||||
|
}
|
||||||
return self;
|
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
|
- (NSDate*) limitDateForMode: (NSString*)mode
|
||||||
{
|
{
|
||||||
id saved_mode;
|
id saved_mode;
|
||||||
|
@ -910,6 +918,8 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
saved_mode = _current_mode;
|
saved_mode = _current_mode;
|
||||||
_current_mode = mode;
|
_current_mode = mode;
|
||||||
|
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
timers = NSMapGet(_mode_2_timers, mode);
|
timers = NSMapGet(_mode_2_timers, mode);
|
||||||
if (timers)
|
if (timers)
|
||||||
{
|
{
|
||||||
|
@ -1018,8 +1028,15 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_current_mode = saved_mode;
|
_current_mode = saved_mode;
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
_current_mode = saved_mode;
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
|
|
||||||
RELEASE(arp);
|
RELEASE(arp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1087,6 +1104,8 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
}
|
}
|
||||||
_current_mode = mode;
|
_current_mode = mode;
|
||||||
|
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
/* Find out how much time we should wait, and set SELECT_TIMEOUT. */
|
/* Find out how much time we should wait, and set SELECT_TIMEOUT. */
|
||||||
if (!limit_date)
|
if (!limit_date)
|
||||||
{
|
{
|
||||||
|
@ -1100,7 +1119,7 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
{
|
{
|
||||||
/* Wait until the LIMIT_DATE. */
|
/* Wait until the LIMIT_DATE. */
|
||||||
if (debug_run_loop)
|
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);
|
[limit_date timeIntervalSinceReferenceDate], ti);
|
||||||
/* If LIMIT_DATE has already past, return immediately. */
|
/* If LIMIT_DATE has already past, return immediately. */
|
||||||
timeout.tv_sec = ti;
|
timeout.tv_sec = ti;
|
||||||
|
@ -1209,18 +1228,25 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
int port_fd_count = 128; // xxx #define this constant
|
int port_fd_count = 128; // xxx #define this constant
|
||||||
int port_fd_array[port_fd_count];
|
int port_fd_array[port_fd_count];
|
||||||
|
|
||||||
if ([port respondsToSelector: @selector(getFds:count:)])
|
if ([port respondsToSelector:
|
||||||
[port getFds: port_fd_array count: &port_fd_count];
|
@selector(getFds:count:)])
|
||||||
|
{
|
||||||
|
[port getFds: port_fd_array
|
||||||
|
count: &port_fd_count];
|
||||||
|
}
|
||||||
if (debug_run_loop)
|
if (debug_run_loop)
|
||||||
|
{
|
||||||
printf("\tNSRunLoop listening to %d sockets\n",
|
printf("\tNSRunLoop listening to %d sockets\n",
|
||||||
port_fd_count);
|
port_fd_count);
|
||||||
|
}
|
||||||
while (port_fd_count--)
|
while (port_fd_count--)
|
||||||
{
|
{
|
||||||
fd = port_fd_array[port_fd_count];
|
fd = port_fd_array[port_fd_count];
|
||||||
FD_SET (port_fd_array[port_fd_count], &read_fds);
|
FD_SET (port_fd_array[port_fd_count], &read_fds);
|
||||||
if (fd > end_inputs)
|
if (fd > end_inputs)
|
||||||
|
{
|
||||||
end_inputs = fd;
|
end_inputs = fd;
|
||||||
|
}
|
||||||
NSMapInsert(_rfdMap,
|
NSMapInsert(_rfdMap,
|
||||||
(void*)port_fd_array[port_fd_count], info);
|
(void*)port_fd_array[port_fd_count], info);
|
||||||
num_inputs++;
|
num_inputs++;
|
||||||
|
@ -1234,24 +1260,29 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
end_inputs++;
|
end_inputs++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there are notifications in the 'idle' queue, we try an instantaneous
|
* If there are notifications in the 'idle' queue, we try an
|
||||||
* select so that, if there is no input pending, we can service the queue.
|
* instantaneous select so that, if there is no input pending,
|
||||||
* Similarly, if a task has completed, we need to deliver it's notifications.
|
* we can service the queue. Similarly, if a task has completed,
|
||||||
|
* we need to deliver it's notifications.
|
||||||
*/
|
*/
|
||||||
if (GSCheckTasks() || GSNotifyMore())
|
if (GSCheckTasks() || GSNotifyMore())
|
||||||
{
|
{
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
select_timeout = &timeout;
|
select_timeout = &timeout;
|
||||||
select_return = select (end_inputs, &read_fds, &write_fds, &exception_fds,
|
select_return = select (end_inputs, &read_fds, &write_fds,
|
||||||
select_timeout);
|
&exception_fds, select_timeout);
|
||||||
}
|
}
|
||||||
else
|
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)
|
if (debug_run_loop)
|
||||||
|
{
|
||||||
printf ("\tNSRunLoop select returned %d\n", select_return);
|
printf ("\tNSRunLoop select returned %d\n", select_return);
|
||||||
|
}
|
||||||
|
|
||||||
if (select_return < 0)
|
if (select_return < 0)
|
||||||
{
|
{
|
||||||
|
@ -1381,7 +1412,6 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
}
|
}
|
||||||
while (fdIndex != fdEnd);
|
while (fdIndex != fdEnd);
|
||||||
|
|
||||||
|
|
||||||
/* Clean up before returning. */
|
/* Clean up before returning. */
|
||||||
NSResetMapTable(_efdMap);
|
NSResetMapTable(_efdMap);
|
||||||
NSResetMapTable(_rfdMap);
|
NSResetMapTable(_rfdMap);
|
||||||
|
@ -1390,6 +1420,13 @@ const NSMapTableValueCallBacks ArrayMapValueCallBacks =
|
||||||
[self _checkPerformers];
|
[self _checkPerformers];
|
||||||
GSNotifyASAP();
|
GSNotifyASAP();
|
||||||
_current_mode = saved_mode;
|
_current_mode = saved_mode;
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
_current_mode = saved_mode;
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
RELEASE(arp);
|
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
|
- (id) initWithTimeInterval: (NSTimeInterval)seconds
|
||||||
targetOrInvocation: (id)t
|
targetOrInvocation: (id)t
|
||||||
selector: (SEL)sel
|
selector: (SEL)sel
|
||||||
|
|
Loading…
Reference in a new issue