• 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: NSURLConnection dependency on RunLoop (Sanity check)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection dependency on RunLoop (Sanity check)


  • Subject: Re: NSURLConnection dependency on RunLoop (Sanity check)
  • From: j o a r <email@hidden>
  • Date: Fri, 22 Jul 2005 10:09:23 +0200


On 22 jul 2005, at 01.31, Andrei Tchijov wrote:

I do appreciate that the code in question, most likely will work just fine in GUI environment (without creating new threads). On other side, the whole idea or "RunLoop" looks very archaic. This is how things used to be programmed before threads were invented.

I don't agree, and I think that your opinion is based on not understanding why run loops are used, or how they work. Any thread that can take external input needs to have some sort of model for how to wait for it and respond to it. This is what a run loop provides. A thread of execution will exit when it's "done", the purpose of the run loop is to keep the thread running for as long as there are run loop input sources that might provide the thread with more stuff to do, and to trigger the appropriate response when new input does arrive.


It will save you from creating extra thread now and then, but is it such a big deal now?

I think that it is a big deal to not have to manage secondary threads for yourself. Thread safe programming is difficult. Most programmers don't know how to do it properly (just see threads on this list where people defend the position that you can achieve thread safety by adding extra retain counts to your objects), or even if they do, it's still a common source for mistakes. Besides, it's a great convenience to have someone else taking care of this for you.


If my program "express desire" to connect to particular URL it should be no one business what else it is doing in the same thread. It is asynchronous call after all.

But that's the point, and the root of your problem. It is an asynchronous call, and you're not listening to the callback because you're blocking the thread. Don't use competing event loop models to wait for events.


j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

This email sent to email@hidden

References: 
 >NSURLConnection dependency on RunLoop (Sanity check) (From: Andrei Tchijov <email@hidden>)
 >Re: NSURLConnection dependency on RunLoop (Sanity check) (From: j o a r <email@hidden>)
 >Re: NSURLConnection dependency on RunLoop (Sanity check) (From: Andrei Tchijov <email@hidden>)

  • Prev by Date: Copying ABPerson (problem with MultiValue fields)
  • Next by Date: Re: EO_Archive files in nibs
  • Previous by thread: Re: NSURLConnection dependency on RunLoop (Sanity check)
  • Next by thread: Bundles and installers...
  • Index(es):
    • Date
    • Thread