• 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
Creating blocking methods which need to receive events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating blocking methods which need to receive events


  • Subject: Creating blocking methods which need to receive events
  • From: Wade Tregaskis <email@hidden>
  • Date: Wed, 30 Jul 2003 17:14:20 +1000

I have a couple of places where I need to block in a method, but I'm awaiting data from a socket, which receives events asynchronously via the current run loop. Obviously if I sit there polling it forever, I'll just lock up. At the moment I'm calling NSRunLoop's runUntilDate method in a loop, until either I time out or I receive data from the socket. But I've seen on a few rare occasions that this creates problems with autoreleased objects - every time I call runUntilDate, it seems, it clears out the autorelease pool. I've proofed my code against this, but I can't expect every thread that uses my code to do the same.

I can't use a separate NSRunLoop, because I'm told which one I must use by NSConnection (this is in an NSPort subclass, FWIW). I've thought about just doing so anyway, but it seems like a lot of effort to create a new run loop for an operation which might only take a few milliseconds.

Obviously there's a heck of a lot of functions which block while waiting for event-driven data, so there must be a lot of examples out there. Can anyone point me to any, or provide any other tips?

Wade Tregaskis
-- Sed quis custodiet ipsos custodes?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Memory Management
  • Next by Date: Change printer in printpanel
  • Previous by thread: Once more with NSTableView headaches...
  • Next by thread: Change printer in printpanel
  • Index(es):
    • Date
    • Thread