Skip navigation.
 
mlRe: Threads, Distributed Objects, and NSUndoManager
FROM : m
DATE : Sun Oct 17 03:47:45 2004

On Oct 16, 2004, at 6:24 PM, John C. Daub wrote:

> If I don't need to use DO, then under what circumstances would I want
> to use
> DO? And in terms of convenience, what exactly is it making more
> convenient
> and how so?


If you have a scenario that requires lots of cross-thread
communication, using DO relieves you from having to worry about most
thread safety issues. But in your case, it's probably overkill, and as
you seemed to have found, has some short comings.

>> Here's a strategy: have your main thread allocate the data object and
>> pass it to your worker thread (without retaining a reference to it),

>
> Why would I not want to retain a reference to it? And what would
> happen if I
> did?


There's no technical reason, it's easier to enforce thread safety if
you don't have a reference to the data object. If you don't have a
reference to the object, you're unlikely to inadvertently do something
with it that violates thread safety.

By the way I'm by no means an expert at threading in Cocoa, just
sharing some of the techniques I developed for myself.

Cheers,

_murat

Related mailsAuthorDate
mlThreads, Distributed Objects, and NSUndoManager John C. Daub Oct 16, 21:40
mlRe: Threads, Distributed Objects, and NSUndoManager m Oct 17, 00:50
mlRe: Threads, Distributed Objects, and NSUndoManager John C. Daub Oct 17, 03:24
mlRe: Threads, Distributed Objects, and NSUndoManager m Oct 17, 03:47
mlRe: Threads, Distributed Objects, and NSUndoManager John C. Daub Oct 17, 04:43