• 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: passing data to threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: passing data to threads


  • Subject: Re: passing data to threads
  • From: "Philip Q" <email@hidden>
  • Date: Wed, 20 Dec 2006 19:31:14 +1300

On 20/12/06, William Irving Zumwalt <email@hidden> wrote:
I'm trying to implement threads and not sure how to pass the *config object
into a newly created thread. I'm using an example from the book Cocoa
Programming.

Anyone have ideas?

There are a few ways to approach this:

- You can use a shared ivar in the NetworkObject that you set and
check/wait on in the thread. This is by far the easiest way, but you
have to be careful and implement good locking on the ivar to avoid any
nasty thread-safety issues.

- You can send the object as part of a method call on the thread. You
can call methods on the thread by using an NSPort. This involves a bit
more setup, but check out ThreadMessage
<http://www.blackholemedia.com/code/> for a simple library that does
it/for some sample code.

-Phil
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >passing data to threads (From: "William Irving Zumwalt" <email@hidden>)

  • Prev by Date: assigning the same keyboard command to more than one menu item
  • Next by Date: Re: Re: Cocoa HTTP Server & threadin
  • Previous by thread: passing data to threads
  • Next by thread: Re: passing data to threads
  • Index(es):
    • Date
    • Thread