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

Tight Runloop


  • Subject: Tight Runloop
  • From: "Ricky McCrae" <email@hidden>
  • Date: Tue, 25 Sep 2007 21:11:39 +1000

Hey,

I have some code that is getting caught in a tight in a tight run loop - it
fulfills its function but locks the UI.

The work needs to be performed is not thread safe and therefor needs to be
performed on the current thread.

Because the code is pseudo asynchronous it is scheduled to run on the
current runloop like so;

[object performSelector:@selector ( someFunction: ) withObject:nil
afterDelay:0.0];

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.

It is possible to refactor everything and have the callback respond through
the chain to the main controller, but this does increase the complexity
somewhat - a linear approach is easier to follow;

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

cheers
_______________________________________________

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

  • Follow-Ups:
    • Re: Tight Runloop
      • From: Alastair Houghton <email@hidden>
    • Re: Tight Runloop
      • From: Brian Smith <email@hidden>
    • Re: Tight Runloop
      • From: NSTask <email@hidden>
  • Prev by Date: Re: Core data or else?
  • Next by Date: Re: Tight Runloop
  • Previous by thread: Re: Problem launching app with embedded frameworks
  • Next by thread: Re: Tight Runloop
  • Index(es):
    • Date
    • Thread