• 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: threads vs run-loops for keeping your GUI responsive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: threads vs run-loops for keeping your GUI responsive


  • Subject: Re: threads vs run-loops for keeping your GUI responsive
  • From: Markus Hitter <email@hidden>
  • Date: Fri, 9 Dec 2005 18:31:04 +0100


Am 09.12.2005 um 18:05 schrieb Joshua D. Orr:

On Dec 9, 2005, at 7:44 AM, Niko Matsakis wrote:

Unfortunately, it is not clear to me how I might schedule a call to this event. I have scoured the wiki and mailing list, but I can't find much mention of this approach: everyone seems to want to create worker threads.

I know I could use NSTimer, but again that doesn't feel quite right: I want the function to be called ASAP, assuming that nothing else is going on; scheduling it for a certain time seems overly complicated.

Surely there is a way to do this? Am I missing something? Is this not a good approach?


[[NSRunLoop currentRunLoop] performSelector:@selector(someMethod)
target:sombObject
argument:nil
order:6
modes:[NSArray arrayWithObject:@"NSDefaultRunLoopMode"]];

'order' defines the priority incase there are more then one events to process.

I accutaly used this method in a run loop running in a separate thread (not the main thread) and it worked great. I am sure it would work fine in the main thread.

Anyway, This will tell the run loop to execute the method next time execution reaches the run loop.

... and other events get inserted as they come in between. I've used this approach in the main loop and it works as expexted.

Still I doubt you gain anything since you still have to split your processing into chunks which usually involves some overhead (storing the current state away, resuming a millisecond later etc.).


Markus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/




_______________________________________________
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: 
 >threads vs run-loops for keeping your GUI responsive (From: Niko Matsakis <email@hidden>)
 >Re: threads vs run-loops for keeping your GUI responsive (From: "Joshua D. Orr" <email@hidden>)

  • Prev by Date: Re: adding an executable as a resource
  • Next by Date: create a bufferarray from a string
  • Previous by thread: Re: threads vs run-loops for keeping your GUI responsive
  • Next by thread: Re: threads vs run-loops for keeping your GUI responsive
  • Index(es):
    • Date
    • Thread