• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Stacking run loops
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stacking run loops


  • Subject: Re: Stacking run loops
  • From: Ricky Sharp <email@hidden>
  • Date: Thu, 23 Dec 2004 08:40:26 -0600


On Dec 16, 2004, at 7:45 AM, Ricky Sharp wrote:

On Thursday, December 16, 2004, at 07:39AM, Ricky Sharp <email@hidden> wrote:


Ultimately, I decided to do things manually with my own local event loop:


modalLoopDone = NO; // iVar

do
{
NSAutoreleasePool* thePool = [[NSAutoreleasePool alloc] init];
NSEvent* theEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantPast] inMode:NSEventTrackingRunLoopMode dequeue:YES];

typo...inMode is actually set to NSDefaultRunLoopMode

		[NSApp sendEvent:theEvent];

		[thePool release];
	}
	while (!modalLoopDone);

Answering my own thread for the sake of the archives...

This loop is very bad in that it needlessly wastes CPU. For what I need, I'm now using distantFuture for my date.

The revised code is now:

modalLoopDone = NO; // iVar

do
{
NSAutoreleasePool* thePool = [[NSAutoreleasePool alloc] init];
NSEvent* theEvent = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];

[NSApp sendEvent:theEvent];

[thePool release];
}
while (!modalLoopDone);


___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Stacking run loops (From: patrick machielse <email@hidden>)
 >Re: Stacking run loops (From: Ricky Sharp <email@hidden>)
 >Re: Stacking run loops (From: Ricky Sharp <email@hidden>)

  • Prev by Date: Re: Why is indexOfObjectIdenticalTo: *far* faster than indexOfObject: ?
  • Next by Date: [OT] [ANN] Alternative object serialization format
  • Previous by thread: Re: Stacking run loops
  • Next by thread: Embedding binary data in an application's property list
  • Index(es):
    • Date
    • Thread