• 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: Techniques for thread communication
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Techniques for thread communication


  • Subject: Re: Techniques for thread communication
  • From: Eric Scharff <email@hidden>
  • Date: Mon, 8 Sep 2003 12:11:27 -0700 (PDT)

> if the worker thread does not touch the result
> thereafter, then you should have no problems.

Well, that's the thing. The getter lock is trying to avoid

1. worker calls setter
2. worker notifies sender on other thread
3. worker continues, calls setter
4. setter calls release on result but hasn't done assignment
yet
5. CONTEXT SWITCH
6. other thread calls result method, gets a now invalid thing

In Java (yeah, I know...) the way that I'd do this is with
syncronization of the instance methods, or

public synchronized void setResult(Result r) { result = r; }
public synchronized Result getResult() { return r; }

So my approach may be over-paranoid, but I don't think it's
broken. :)

-Eric

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
_______________________________________________
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.

  • Follow-Ups:
    • Re: Techniques for thread communication
      • From: Greg Titus <email@hidden>
References: 
 >Re: Techniques for thread communication (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: Techniques for thread communication
  • Next by Date: Re: NSComboBox problem
  • Previous by thread: Re: Techniques for thread communication
  • Next by thread: Re: Techniques for thread communication
  • Index(es):
    • Date
    • Thread