• 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: Bill Bumgarner <email@hidden>
  • Date: Tue, 17 May 2011 10:02:22 -0700

On May 17, 2011, at 9:54 AM, Bing Li wrote:

> 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?

Sure -- if you want to re-invent the wheel and ensure that you don't make a wheel as round as the one that is provided by the frameworks.

The run loops are implemented very efficiently;  they use various kernel primitives to ensure that a wide variety of event sources can be used without needing polling internally.

Similarly, GCD's dispatch sources allow for similar event response patterns while using queues.

All of these will be preferable to spawning a thread and parking it.   A parked thread still uses resources;  it still consumes kernel resources (kernel has to maintain the execution context and stack and, when it runs, schedule it) and it consumes user space memory.

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

References: 
 >Why RunLoop? (From: Bing Li <email@hidden>)
 >Re: Why RunLoop? (From: Bill Bumgarner <email@hidden>)
 >Re: Why RunLoop? (From: Bing Li <email@hidden>)

  • Prev by Date: Re: Why RunLoop?
  • 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