• 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
communication with blocking threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

communication with blocking threads


  • Subject: communication with blocking threads
  • From: Chaz McGarvey <email@hidden>
  • Date: Sat, 27 Dec 2003 17:47:45 -0700

Hello:

I have a question regarding what I should do when two threads need to communicate with one another, but one thread needs to block. Specifically, I have a thread that listens and accepts connections on a port, and accept() blocks. When a connection is received on the port, it needs to send a message to the other thread (which does not block) using an NSConnection. But because the listening thread is blocking, it can't really be sent messages back in the same way. The only reason I would want to send messages from the non-blocking thread to the listener thread is to tell it to stop listening (and ending that thread). I currently get around this by passing back the socket that the listener thread is listening on to the non-blocking thread. Then the non-blocking thread closes the socket itself, and then the listener thread terminates itself. This seems really hacky and inflexible, though, and I really hope someone can propose a better solution. Ideally, accept() would magically return control back to the runloop whenever there is a message there, but I don't know how to go about doing this.

Thanks in advance,
Chaz McGarvey
_______________________________________________
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: character spacing
  • Next by Date: Sorting NSTableView columns using new Panther methods
  • Previous by thread: Re: character spacing
  • Next by thread: Sorting NSTableView columns using new Panther methods
  • Index(es):
    • Date
    • Thread