• 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: Cocoa threading, objects by reference, and the keyword "oneway"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa threading, objects by reference, and the keyword "oneway"


  • Subject: Re: Cocoa threading, objects by reference, and the keyword "oneway"
  • From: j o a r <email@hidden>
  • Date: Wed, 6 Jun 2001 19:04:36 +0200

On onsdag, juni 6, 2001, at 02:19 , Andreas Doerr wrote:

I don't understand, why you are using the 'oneway' keyword at all! This keyword
is used in the context of remote messaging. If you want to pass a reference
between to threads (which share the same address space) why don't you just pass
it? Of course, you have to synchronize access to this memory location.

I trained myself in NSThread using samplecode from Apple (SimpleThreads and TrivialThreads). They used the oneway keyword to make the communication between local threads thread safe. I snipped some of the comments from the sample code:

// Starts a slow transfer operation. The server thread
// will spend a lot of time doing this operation, occasionally
// sending messages back to the controller to inform it of
// its progress. Note that because the message is "oneway",
// the thread that invokes this method will continue running,
// despite the fact that the server thread is off doing
// things.

and

// Appends theString to the output text field. This routine is
// callable both by the controller object running in the main
// thread, and by the server object running in a secondary thread.
// The "oneway" type qualifier informs the Distributed Object
// system that it does not have to wait for this message to be
// delivered before letting the sender continue running. This
// is a sensible thing to do for things like updating progress
// information, because you don't want your threaded operation
// to stop and wait to synchronise with the main thread just so
// that you can confirm that the progress bar has been updated
// correctly.

It seems to me that DO can be a useful, if somewhat cumbersome, method to communicate between threads in a process - and not only for communication between processes (don't let the reference to the "server thread" in the comment above fool you - it is still communication between threads in the same process)

Regards,

j o a r


References: 
 >Re: Cocoa threading, objects by reference, and the keyword "oneway" (From: Andreas Doerr <email@hidden>)

  • Prev by Date: Re: Program Efficiency
  • Next by Date: Re: LoadNib not working
  • Previous by thread: Re: Cocoa threading, objects by reference, and the keyword "oneway"
  • Next by thread: Re: Cocoa threading, objects by reference, and the keyword "oneway"
  • Index(es):
    • Date
    • Thread