• 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: Multithreading Dilemma
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multithreading Dilemma


  • Subject: Re: Multithreading Dilemma
  • From: Dustin Voss <email@hidden>
  • Date: Sat, 17 May 2003 14:40:46 -0700

Try the InterThreadMessaging library by Toby Paterson. I've successfully used it for bi-directional communication between my own main and socket thread. It is documented at http://cocoadev.com/index.pl?InterThreadMessaging, and available from my iDisk.

On a side note, I've written an AsyncSocket class (http://cocoadev.com/index.pl?
AsyncSocket) that works with run-loops instead of threads. You may find it easier to integrate than SmallSockets.

On Friday, May 16, 2003, at 08:57 PM, Jean-Olivier Lancttt-D. wrote:

Hi list,

You guys are like my last resort, I tried EVERYTHING today :)

Here's the situation:

I have two majors objects in my game: a WarController which handles communication with all the game's view: e.g. the board, the score view, etc and a CommController which handles communication with the remote player (multiplayer). I use my customized version of SmallSockets ( I implemented timeouts and other stuff ) with **threads** to communicate.

Suppose I want to host a game, I send - listenInBackground to the CommController. it sets up a socket, and then spawns a thread which will WAIT (block) till someone connects. Then it will read data until an exception is raised. Each time it gets new data, it passes back the data to a "parsing" function inside CommController too.

That same parsing method first parses the important info out of the packet AND THEN reacts to that data. Suppose the remote player sent a packet saying that he's moved from E3 to D2 or whatever (it's not important). Well that method needs to _*communicate*_ with WarController (**NOT IN THE SAME THREAD**). It sends a setState: message to WarController which in turns updates the UI accordingly (**calling appkit objects**)... The problem is that the appkit objects don't react to those methods.

I tried performSelectorInMainThread, NSConnections (as seen in SAnguish's Cocoa Book), pretty much everything I can think of... still.. doesn't work.

Help!

Thanks in advance!

--Jean-Olivier Lancttt-David
_______________________________________________
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.
_______________________________________________
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.

References: 
 >Multithreading Dilemma (From: "Jean-Olivier Lanctôt-D." <email@hidden>)

  • Prev by Date: tableviews, strings, columns, complicated
  • Next by Date: Re: Calculation by string
  • Previous by thread: Multithreading Dilemma
  • Next by thread: Re: zeroing out unused bytes from NSData
  • Index(es):
    • Date
    • Thread