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

Re: Background Process?


  • Subject: Re: Background Process?
  • From: Roland King <email@hidden>
  • Date: Wed, 11 Mar 2009 13:53:43 +0800

Kyle Sluder wrote:

On Tue, Mar 10, 2009 at 11:38 PM, Michael Ash <email@hidden> wrote:


The notion that adding a timer to a runloop would somehow cause that
runloop to suck up CPU time when the runloop is idle is nonsensical.
The whole point of the runloop is that it sleeps the process until
some activity is required. A background process sitting on a timer
*will* take up various resources (memory, file descriptors, kernel
structures, etc.) but CPU time is not among them.



That's not what I said. What I said was that you cannot add a timer to your runloop and expect it to sit blocking on it until the timer fires. That's not how timers operate. You will need to periodically run the runloop in order to get your timer to fire. If you are doing this in an application, then the event-processing functionality of the runloop will take care of it. Otherwise, you will need to run it yourself. Either way, you will need to periodically poke the runloop, which on it's face can't take 0.0% CPU. Your app will persistently wake up (and our friend Nyquist has proven that in order for this to work it must wake at least twice as often as you want the timer to fire).

--Kyle Sluder


This isn't how I understood the runloop documentation when I read it, and it's more than possible I have totally misread it. In the runloop documentation it says that at step '7'

*Put the thread to sleep until one of the following events occurs:

   An event arrives for a port-based input source
   A timer fires
   The timeout value set for the runloop expires
   The runloop is explicitly woken up.*

So you just add the timer to the runloop, run it, it sleeps until the timer fires, does its thing and then goes back to sleep again. What am I missing?


_______________________________________________

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: Background Process?
      • From: Kyle Sluder <email@hidden>
References: 
 >Background Process? (From: Pierce Freeman <email@hidden>)
 >Re: Background Process? (From: Daniel Richman <email@hidden>)
 >Re: Background Process? (From: Kyle Sluder <email@hidden>)
 >Re: Background Process? (From: Roland King <email@hidden>)
 >Re: Background Process? (From: Kyle Sluder <email@hidden>)
 >Re: Background Process? (From: Chris Suter <email@hidden>)
 >Re: Background Process? (From: Darren Minifie <email@hidden>)
 >Re: Background Process? (From: Michael Ash <email@hidden>)
 >Re: Background Process? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: KVO & Bindings: Proxy object & change notifications
  • Next by Date: Re: Remote Invocation
  • Previous by thread: Re: Background Process?
  • Next by thread: Re: Background Process?
  • Index(es):
    • Date
    • Thread