mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Deprecate old message access method ... we can be a lot more efficient if
we don't have to support it. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21922 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
eaf8db8c42
commit
7087d02211
3 changed files with 104 additions and 69 deletions
|
@ -11,6 +11,8 @@
|
||||||
messages.
|
messages.
|
||||||
* Source/GNUmakefile: Don't install private headers in public area.
|
* Source/GNUmakefile: Don't install private headers in public area.
|
||||||
* Source/win32/GSRunLoopCtxt.m: Add code to handle windows messages.
|
* Source/win32/GSRunLoopCtxt.m: Add code to handle windows messages.
|
||||||
|
Check number of handles waited for. Avoid unnecessary heap memory
|
||||||
|
allocation/release.
|
||||||
* Source/win32/GSRunLoopWatcher.m: update header path.
|
* Source/win32/GSRunLoopWatcher.m: update header path.
|
||||||
* Source/win32/NSRunLoopWin32.m: update header path.
|
* Source/win32/NSRunLoopWin32.m: update header path.
|
||||||
* Source/win32/NSUserDefaultsWin32.m: update header path.
|
* Source/win32/NSUserDefaultsWin32.m: update header path.
|
||||||
|
|
|
@ -140,7 +140,7 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
||||||
{
|
{
|
||||||
NSMapEnumerator hEnum;
|
NSMapEnumerator hEnum;
|
||||||
GSRunLoopWatcher *watcher;
|
GSRunLoopWatcher *watcher;
|
||||||
HANDLE *handleArray;
|
HANDLE handleArray[MAXIMUM_WAIT_OBJECTS-1];
|
||||||
int num_handles;
|
int num_handles;
|
||||||
int num_winMsgs;
|
int num_winMsgs;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -226,14 +226,19 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
||||||
wait_timeout = 0;
|
wait_timeout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleArray = (HANDLE*)NSZoneMalloc(NSDefaultMallocZone(),
|
|
||||||
sizeof(HANDLE) * num_handles);
|
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
hEnum = NSEnumerateMapTable(handleMap);
|
hEnum = NSEnumerateMapTable(handleMap);
|
||||||
while (NSNextMapEnumeratorPair(&hEnum, &handle, (void**)&watcher))
|
while (NSNextMapEnumeratorPair(&hEnum, &handle, (void**)&watcher))
|
||||||
{
|
{
|
||||||
handleArray[i++] = (HANDLE)handle;
|
if (i < MAXIMUM_WAIT_OBJECTS-1)
|
||||||
|
{
|
||||||
|
handleArray[i++] = (HANDLE)handle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSLog(@"Too many handles to wait for ... only using %d of %d",
|
||||||
|
i, num_handles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NSEndMapTableEnumeration(&hEnum);
|
NSEndMapTableEnumeration(&hEnum);
|
||||||
num_handles = i;
|
num_handles = i;
|
||||||
|
@ -251,24 +256,25 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
||||||
MSG msg;
|
MSG msg;
|
||||||
INT bRet;
|
INT bRet;
|
||||||
|
|
||||||
if (num_winMsgs > 0)
|
if (msgTarget == nil)
|
||||||
{
|
{
|
||||||
GSRunLoopWatcher *generic = nil;
|
bRet = PeekMessage(&msg, 0, 0, 0, PM_REMOVE);
|
||||||
unsigned num = num_winMsgs;
|
if (bRet != 0)
|
||||||
|
|
||||||
hEnum = NSEnumerateMapTable(winMsgMap);
|
|
||||||
while (NSNextMapEnumeratorPair(&hEnum, &handle, (void**)&watcher))
|
|
||||||
{
|
{
|
||||||
if (watcher->_invalidated == NO)
|
if (num_winMsgs > 0)
|
||||||
{
|
{
|
||||||
if (handle == 0 && num > 1)
|
HANDLE handle;
|
||||||
|
|
||||||
|
handle = msg.hwnd;
|
||||||
|
watcher = (GSRunLoopWatcher*)NSMapGet(winMsgMap,
|
||||||
|
(void*)handle);
|
||||||
|
if (watcher == nil || watcher->_invalidated == YES)
|
||||||
{
|
{
|
||||||
// Let window specific watchers have first attempt.
|
handle = 0; // Generic
|
||||||
generic = watcher;
|
watcher = (GSRunLoopWatcher*)NSMapGet(winMsgMap,
|
||||||
continue;
|
(void*)handle);
|
||||||
}
|
}
|
||||||
bRet = PeekMessage(&msg, handle, 0, 0, PM_REMOVE);
|
if (watcher != nil && watcher->_invalidated == NO)
|
||||||
if (bRet != 0)
|
|
||||||
{
|
{
|
||||||
i = [contexts count];
|
i = [contexts count];
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
|
@ -280,66 +286,95 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
||||||
[c endEvent: (void*)handle type: ET_WINMSG];
|
[c endEvent: (void*)handle type: ET_WINMSG];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NSEndMapTableEnumeration(&hEnum);
|
|
||||||
NSZoneFree(NSDefaultMallocZone(), handleArray);
|
|
||||||
completed = YES;
|
completed = YES;
|
||||||
/*
|
/*
|
||||||
* The watcher is still valid - so call the
|
* The watcher is still valid - so call the
|
||||||
* receiver's event handling method.
|
* receiver's event handling method.
|
||||||
*/
|
*/
|
||||||
(*watcher->handleEvent)(watcher->receiver,
|
(*watcher->handleEvent)(watcher->receiver,
|
||||||
|
eventSel, watcher->data, watcher->type,
|
||||||
|
(void*)(gsaddr)&msg, mode);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (num_winMsgs > 0)
|
||||||
|
{
|
||||||
|
GSRunLoopWatcher *generic = nil;
|
||||||
|
unsigned num = num_winMsgs;
|
||||||
|
|
||||||
|
hEnum = NSEnumerateMapTable(winMsgMap);
|
||||||
|
while (NSNextMapEnumeratorPair(&hEnum, &handle,
|
||||||
|
(void**)&watcher))
|
||||||
|
{
|
||||||
|
if (watcher->_invalidated == NO)
|
||||||
|
{
|
||||||
|
if (handle == 0 && num > 1)
|
||||||
|
{
|
||||||
|
// Let window specific watchers have first attempt.
|
||||||
|
generic = watcher;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
bRet = PeekMessage(&msg, handle, 0, 0, PM_REMOVE);
|
||||||
|
if (bRet != 0)
|
||||||
|
{
|
||||||
|
i = [contexts count];
|
||||||
|
while (i-- > 0)
|
||||||
|
{
|
||||||
|
GSRunLoopCtxt *c = [contexts objectAtIndex: i];
|
||||||
|
|
||||||
|
if (c != self)
|
||||||
|
{
|
||||||
|
[c endEvent: (void*)handle
|
||||||
|
type: ET_WINMSG];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NSEndMapTableEnumeration(&hEnum);
|
||||||
|
completed = YES;
|
||||||
|
/*
|
||||||
|
* The watcher is still valid - so call the
|
||||||
|
* receiver's event handling method.
|
||||||
|
*/
|
||||||
|
(*watcher->handleEvent)(watcher->receiver,
|
||||||
|
eventSel, watcher->data, watcher->type,
|
||||||
|
(void*)(gsaddr)&msg, mode);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
num--;
|
||||||
|
}
|
||||||
|
NSEndMapTableEnumeration(&hEnum);
|
||||||
|
if (generic != nil && generic->_invalidated == NO)
|
||||||
|
{
|
||||||
|
bRet = PeekMessage(&msg, 0, 0, 0, PM_REMOVE);
|
||||||
|
if (bRet != 0)
|
||||||
|
{
|
||||||
|
i = [contexts count];
|
||||||
|
while (i-- > 0)
|
||||||
|
{
|
||||||
|
GSRunLoopCtxt *c = [contexts objectAtIndex: i];
|
||||||
|
|
||||||
|
if (c != self)
|
||||||
|
{
|
||||||
|
[c endEvent: (void*)0 type: ET_WINMSG];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NSEndMapTableEnumeration(&hEnum);
|
||||||
|
completed = YES;
|
||||||
|
(*generic->handleEvent)(watcher->receiver,
|
||||||
eventSel, watcher->data, watcher->type,
|
eventSel, watcher->data, watcher->type,
|
||||||
(void*)(gsaddr)&msg, mode);
|
(void*)(gsaddr)&msg, mode);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
num--;
|
|
||||||
}
|
|
||||||
NSEndMapTableEnumeration(&hEnum);
|
|
||||||
if (generic != nil && generic->_invalidated == NO)
|
|
||||||
{
|
|
||||||
bRet = PeekMessage(&msg, 0, 0, 0, PM_REMOVE);
|
|
||||||
if (bRet != 0)
|
|
||||||
{
|
|
||||||
i = [contexts count];
|
|
||||||
while (i-- > 0)
|
|
||||||
{
|
|
||||||
GSRunLoopCtxt *c = [contexts objectAtIndex: i];
|
|
||||||
|
|
||||||
if (c != self)
|
|
||||||
{
|
|
||||||
[c endEvent: (void*)0 type: ET_WINMSG];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NSEndMapTableEnumeration(&hEnum);
|
|
||||||
NSZoneFree(NSDefaultMallocZone(), handleArray);
|
|
||||||
completed = YES;
|
|
||||||
(*generic->handleEvent)(watcher->receiver,
|
|
||||||
eventSel, watcher->data, watcher->type,
|
|
||||||
(void*)(gsaddr)&msg, mode);
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msgTarget != nil)
|
|
||||||
{
|
|
||||||
NSZoneFree(NSDefaultMallocZone(), handleArray);
|
|
||||||
completed = YES;
|
|
||||||
[msgTarget performSelector: msgSelector withObject: nil];
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((bRet = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) != 0)
|
|
||||||
{
|
|
||||||
if (bRet == -1)
|
|
||||||
{
|
|
||||||
// handle the error and possibly exit
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
}
|
}
|
||||||
|
completed = YES;
|
||||||
|
[msgTarget performSelector: msgSelector withObject: nil];
|
||||||
|
return NO;
|
||||||
}
|
}
|
||||||
--wait_timeout;
|
--wait_timeout;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +396,6 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
||||||
// if there arent events
|
// if there arent events
|
||||||
if (wait_return == WAIT_TIMEOUT)
|
if (wait_return == WAIT_TIMEOUT)
|
||||||
{
|
{
|
||||||
NSZoneFree(NSDefaultMallocZone(), handleArray);
|
|
||||||
completed = YES;
|
completed = YES;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
@ -401,7 +435,6 @@ static const NSMapTableValueCallBacks WatcherMapValueCallBacks =
|
||||||
|
|
||||||
GSNotifyASAP();
|
GSNotifyASAP();
|
||||||
|
|
||||||
NSZoneFree(NSDefaultMallocZone(), handleArray);
|
|
||||||
completed = YES;
|
completed = YES;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
{
|
{
|
||||||
GSRunLoopCtxt *context;
|
GSRunLoopCtxt *context;
|
||||||
|
|
||||||
// GSOnceMLog(@"This method is deprecated, use -addEvent:type:watcher:forMode");
|
GSOnceMLog(@"This method is deprecated, use -addEvent:type:watcher:forMode");
|
||||||
context = NSMapGet(_contextMap, mode);
|
context = NSMapGet(_contextMap, mode);
|
||||||
if (context == nil)
|
if (context == nil)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue