• 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: Tight Runloop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tight Runloop


  • Subject: Re: Tight Runloop
  • From: Brian Smith <email@hidden>
  • Date: Tue, 25 Sep 2007 06:56:47 -0600


On Sep 25, 2007, at 5:11 AM, Ricky McCrae wrote:


someFunction communicates with another object and needs to wait for a
callback so its occupying itself while it waits for the callback like so;


do
{
   [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
beforeDate:[NSDate dateWithTimeIntervalSinceNow: 2]];
}while(somecondition);

The callback is processed and the condition is met, the UI receives updates
but mouse events are not processed.



Is this the correct way to 'occupy' a function or is this a great example of
what not to do;



This doesn't seem to be a great way to do this as the main threads run loop is already running, and you function just hijacked it and started it running again. So, I think the behavior is undefined as your seeing. Plus to get this working, I think you would have to not re-run the run loop but take over event processing. What you are trying to do suggest that someFunction should be run in a thread as it will have its own run loop and won't block the rest of the application while it waits. Since you have an event, the callback, you might want to reconsider your design to be asynchronous, such that you start the process in someFunction and then your callback finishes it. So, ask yourself, why does someFunction need to wait?

Brian
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Tight Runloop (From: "Ricky McCrae" <email@hidden>)

  • Prev by Date: Re: Problem launching app with embedded frameworks
  • Next by Date: Re: [resolved] Re: really weird move file problem -- bonus points to Jon Hendry
  • Previous by thread: Re: Tight Runloop
  • Next by thread: Re: Tight Runloop
  • Index(es):
    • Date
    • Thread