mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +00:00
Tidy
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4591 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fc054337ac
commit
ae3eeab2f6
1 changed files with 93 additions and 89 deletions
|
@ -23,10 +23,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Implementation for NSNotificationQueue for GNUStep
|
/* Implementation for NSNotificationQueue for GNUStep
|
||||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
Copyright (C) 1997-1999 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Modified by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Modified by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
Date: 1997
|
Date: 1997
|
||||||
|
Rewritten: 1999
|
||||||
|
|
||||||
This file is part of the GNUstep Base Library.
|
This file is part of the GNUstep Base Library.
|
||||||
|
|
||||||
|
@ -122,7 +123,7 @@ currentList()
|
||||||
list->next = elem;
|
list->next = elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)unregisterQueue: (NSNotificationQueue*)q
|
+ (void) unregisterQueue: (NSNotificationQueue*)q
|
||||||
{
|
{
|
||||||
NotificationQueueList* list;
|
NotificationQueueList* list;
|
||||||
|
|
||||||
|
@ -246,21 +247,21 @@ add_to_queue(
|
||||||
NSArray* modes,
|
NSArray* modes,
|
||||||
NSZone* zone)
|
NSZone* zone)
|
||||||
{
|
{
|
||||||
NSNotificationQueueRegistration* item =
|
NSNotificationQueueRegistration* item =
|
||||||
NSZoneCalloc(zone, 1, sizeof(NSNotificationQueueRegistration));
|
NSZoneCalloc(zone, 1, sizeof(NSNotificationQueueRegistration));
|
||||||
|
|
||||||
item->notification = RETAIN(notification);
|
item->notification = RETAIN(notification);
|
||||||
item->name = [notification name];
|
item->name = [notification name];
|
||||||
item->object = [notification object];
|
item->object = [notification object];
|
||||||
item->modes = [modes copyWithZone: [modes zone]];
|
item->modes = [modes copyWithZone: [modes zone]];
|
||||||
|
|
||||||
item->prev = NULL;
|
item->prev = NULL;
|
||||||
item->next = queue->tail;
|
item->next = queue->tail;
|
||||||
queue->tail = item;
|
queue->tail = item;
|
||||||
if (item->next)
|
if (item->next)
|
||||||
item->next->prev = item;
|
item->next->prev = item;
|
||||||
if (!queue->head)
|
if (!queue->head)
|
||||||
queue->head = item;
|
queue->head = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,7 +272,7 @@ add_to_queue(
|
||||||
|
|
||||||
@implementation NSNotificationQueue
|
@implementation NSNotificationQueue
|
||||||
|
|
||||||
+ (NSNotificationQueue*)defaultQueue
|
+ (NSNotificationQueue*) defaultQueue
|
||||||
{
|
{
|
||||||
NotificationQueueList *list;
|
NotificationQueueList *list;
|
||||||
NSNotificationQueue *item;
|
NSNotificationQueue *item;
|
||||||
|
@ -282,19 +283,19 @@ add_to_queue(
|
||||||
{
|
{
|
||||||
item = (NSNotificationQueue*)NSAllocateObject(self,
|
item = (NSNotificationQueue*)NSAllocateObject(self,
|
||||||
0, NSDefaultMallocZone());
|
0, NSDefaultMallocZone());
|
||||||
item = [item initWithNotificationCenter:
|
item = [item initWithNotificationCenter:
|
||||||
[NSNotificationCenter defaultCenter]];
|
[NSNotificationCenter defaultCenter]];
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)init
|
- (id) init
|
||||||
{
|
{
|
||||||
return [self initWithNotificationCenter:
|
return [self initWithNotificationCenter:
|
||||||
[NSNotificationCenter defaultCenter]];
|
[NSNotificationCenter defaultCenter]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithNotificationCenter: (NSNotificationCenter*)notificationCenter
|
- (id) initWithNotificationCenter: (NSNotificationCenter*)notificationCenter
|
||||||
{
|
{
|
||||||
zone = [self zone];
|
zone = [self zone];
|
||||||
|
|
||||||
|
@ -309,68 +310,70 @@ add_to_queue(
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
NSNotificationQueueRegistration* item;
|
NSNotificationQueueRegistration *item;
|
||||||
|
|
||||||
// remove from classs instances list
|
// remove from class instances list
|
||||||
[NotificationQueueList unregisterQueue: self];
|
[NotificationQueueList unregisterQueue: self];
|
||||||
|
|
||||||
// release self
|
// release self
|
||||||
for (item = asapQueue->head; item; item=item->prev)
|
for (item = asapQueue->head; item; item=item->prev)
|
||||||
remove_from_queue(asapQueue, item, zone);
|
remove_from_queue(asapQueue, item, zone);
|
||||||
NSZoneFree(zone, asapQueue);
|
NSZoneFree(zone, asapQueue);
|
||||||
|
|
||||||
for (item = idleQueue->head; item; item=item->prev)
|
for (item = idleQueue->head; item; item=item->prev)
|
||||||
remove_from_queue(idleQueue, item, zone);
|
remove_from_queue(idleQueue, item, zone);
|
||||||
NSZoneFree(zone, idleQueue);
|
NSZoneFree(zone, idleQueue);
|
||||||
|
|
||||||
RELEASE(center);
|
RELEASE(center);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inserting and Removing Notifications From a Queue */
|
/* Inserting and Removing Notifications From a Queue */
|
||||||
|
|
||||||
- (void)dequeueNotificationsMatching: (NSNotification*)notification
|
- (void) dequeueNotificationsMatching: (NSNotification*)notification
|
||||||
coalesceMask: (NSNotificationCoalescing)coalesceMask
|
coalesceMask: (NSNotificationCoalescing)coalesceMask
|
||||||
{
|
{
|
||||||
NSNotificationQueueRegistration* item;
|
NSNotificationQueueRegistration* item;
|
||||||
NSNotificationQueueRegistration* next;
|
NSNotificationQueueRegistration* next;
|
||||||
id name = [notification name];
|
id name = [notification name];
|
||||||
id object = [notification object];
|
id object = [notification object];
|
||||||
|
|
||||||
// find in ASAP notification in queue
|
// find in ASAP notification in queue
|
||||||
for (item = asapQueue->tail; item; item=next) {
|
for (item = asapQueue->tail; item; item=next)
|
||||||
next = item->next;
|
{
|
||||||
if ((coalesceMask & NSNotificationCoalescingOnName)
|
next = item->next;
|
||||||
&& [name isEqual: item->name])
|
if ((coalesceMask & NSNotificationCoalescingOnName)
|
||||||
{
|
&& [name isEqual: item->name])
|
||||||
remove_from_queue(asapQueue, item, zone);
|
{
|
||||||
continue;
|
remove_from_queue(asapQueue, item, zone);
|
||||||
}
|
continue;
|
||||||
if ((coalesceMask & NSNotificationCoalescingOnSender)
|
}
|
||||||
&& (object == item->object))
|
if ((coalesceMask & NSNotificationCoalescingOnSender)
|
||||||
{
|
&& (object == item->object))
|
||||||
remove_from_queue(asapQueue, item, zone);
|
{
|
||||||
continue;
|
remove_from_queue(asapQueue, item, zone);
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// find in idle notification in queue
|
// find in idle notification in queue
|
||||||
for (item = idleQueue->tail; item; item=next) {
|
for (item = idleQueue->tail; item; item=next)
|
||||||
next = item->next;
|
{
|
||||||
if ((coalesceMask & NSNotificationCoalescingOnName)
|
next = item->next;
|
||||||
&& [name isEqual: item->name])
|
if ((coalesceMask & NSNotificationCoalescingOnName)
|
||||||
{
|
&& [name isEqual: item->name])
|
||||||
remove_from_queue(asapQueue, item, zone);
|
{
|
||||||
continue;
|
remove_from_queue(asapQueue, item, zone);
|
||||||
}
|
continue;
|
||||||
if ((coalesceMask & NSNotificationCoalescingOnSender)
|
}
|
||||||
&& (object == item->object))
|
if ((coalesceMask & NSNotificationCoalescingOnSender)
|
||||||
{
|
&& (object == item->object))
|
||||||
remove_from_queue(asapQueue, item, zone);
|
{
|
||||||
continue;
|
remove_from_queue(asapQueue, item, zone);
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,35 +390,36 @@ add_to_queue(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)enqueueNotification: (NSNotification*)notification
|
- (void) enqueueNotification: (NSNotification*)notification
|
||||||
postingStyle: (NSPostingStyle)postingStyle
|
postingStyle: (NSPostingStyle)postingStyle
|
||||||
{
|
{
|
||||||
[self enqueueNotification: notification
|
[self enqueueNotification: notification
|
||||||
postingStyle: postingStyle
|
postingStyle: postingStyle
|
||||||
coalesceMask: NSNotificationCoalescingOnName +
|
coalesceMask: NSNotificationCoalescingOnName
|
||||||
NSNotificationCoalescingOnSender
|
+ NSNotificationCoalescingOnSender
|
||||||
forModes: nil];
|
forModes: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)enqueueNotification: (NSNotification*)notification
|
- (void) enqueueNotification: (NSNotification*)notification
|
||||||
postingStyle: (NSPostingStyle)postingStyle
|
postingStyle: (NSPostingStyle)postingStyle
|
||||||
coalesceMask: (NSNotificationCoalescing)coalesceMask
|
coalesceMask: (NSNotificationCoalescing)coalesceMask
|
||||||
forModes: (NSArray*)modes
|
forModes: (NSArray*)modes
|
||||||
{
|
{
|
||||||
if (coalesceMask != NSNotificationNoCoalescing)
|
if (coalesceMask != NSNotificationNoCoalescing)
|
||||||
[self dequeueNotificationsMatching: notification
|
[self dequeueNotificationsMatching: notification
|
||||||
coalesceMask: coalesceMask];
|
coalesceMask: coalesceMask];
|
||||||
|
|
||||||
switch (postingStyle) {
|
switch (postingStyle)
|
||||||
case NSPostNow:
|
{
|
||||||
[self postNotification: notification forModes: modes];
|
case NSPostNow:
|
||||||
break;
|
[self postNotification: notification forModes: modes];
|
||||||
case NSPostASAP:
|
break;
|
||||||
add_to_queue(asapQueue, notification, modes, zone);
|
case NSPostASAP:
|
||||||
break;
|
add_to_queue(asapQueue, notification, modes, zone);
|
||||||
case NSPostWhenIdle:
|
break;
|
||||||
add_to_queue(idleQueue, notification, modes, zone);
|
case NSPostWhenIdle:
|
||||||
break;
|
add_to_queue(idleQueue, notification, modes, zone);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue