• 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: Why RunLoop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why RunLoop?


  • Subject: Re: Why RunLoop?
  • From: Bing Li <email@hidden>
  • Date: Wed, 18 May 2011 00:54:29 +0800

Dear Bill,

You are right. Polling is not good.

But I noticed that Cocoa threading provides wait/pulse-like synchronization
techniques, such as Condition. I believe these techniques can be used to
control a thread which has a while-true loop. So I think RunLoop can be
replaced. Do you think so?

Best,
Bing

On Tue, May 17, 2011 at 5:45 AM, Bill Bumgarner <email@hidden> wrote:

> In short, do **not** poll.  Not ever.
>
> If you are doing something like this:
>
>        while (stillDontGotIt) {
>              sleepForAMomentAndHopeWeGetIt();
>        }
>
> (or the obvious spin-and-try-lock variant).
>
> Then you are doing it wrong.
>
> It eats CPU, makes your app less responsive, eats battery life, and is less
> efficient.   Far far more efficient is to set up various triggers or points
> of coordination -- queues, callbacks, run loop events, etc… -- through which
> your app will be notified when something is ready to be processed.
>
> b.bum
_______________________________________________

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: Why RunLoop?
      • From: "Zajkowski, James" <email@hidden>
    • Re: Why RunLoop?
      • From: Wim Lewis <email@hidden>
    • Re: Why RunLoop?
      • From: Bill Bumgarner <email@hidden>
    • Re: Why RunLoop?
      • From: David Duncan <email@hidden>
References: 
 >Why RunLoop? (From: Bing Li <email@hidden>)
 >Re: Why RunLoop? (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: Core Animation animations stop prematurely at random
  • Next by Date: Re: Core Animation animations stop prematurely at random
  • Previous by thread: Re: Why RunLoop?
  • Next by thread: Re: Why RunLoop?
  • Index(es):
    • Date
    • Thread