• 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: Does CFSocket use efficient polling?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does CFSocket use efficient polling?


  • Subject: Re: Does CFSocket use efficient polling?
  • From: Eli Bach <email@hidden>
  • Date: Thu, 12 Feb 2009 13:14:45 -0800


On Feb 12, 2009, at 1:07 PM, Joel Reymont wrote:

On Feb 12, 2009, at 8:50 PM, Josh Graessley wrote:

In my experience, there are two good reasons to use a thread:
1) You're CPU bound so you need to utilize multiple cores
2) You're using a poorly designed API - synchronous APIs are a good example


I'm with you Josh! How do I get notified that there's data to be read from a socket _without_ using a separate thread and without busy-polling?

I don't know if CFSocket allocates a single buffer and reuses it, for example.

I want to use a single buffer of an exact size and I don't need NSData back.

It looks like I need to use the BSD socket API but I suspect that checking the socket every time my audio playback callback is triggered may not be optimal. I'd rather check the socket, receive data and post it to a buffer outside of my audio callback.

Can this actually be done without using a separate thread?

Thanks, Joel

Well, CFReadStream will do this, assuming you are using a runloop. But behind the scene's, it makes a separate thread for calling the bsd networking api's (at least on Mac OS X, but it's probably the same on the iPhoneOS).


Eli

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Does CFSocket use efficient polling?
      • From: Joel Reymont <email@hidden>
References: 
 >Re: Does CFSocket use efficient polling? (From: Scott Ribe <email@hidden>)
 >Re: Does CFSocket use efficient polling? (From: Josh Graessley <email@hidden>)
 >Re: Does CFSocket use efficient polling? (From: Joel Reymont <email@hidden>)

  • Prev by Date: Re: Does CFSocket use efficient polling?
  • Next by Date: Re: Does CFSocket use efficient polling?
  • Previous by thread: Re: Does CFSocket use efficient polling?
  • Next by thread: Re: Does CFSocket use efficient polling?
  • Index(es):
    • Date
    • Thread