"Darin Fisher" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> mark kaplun wrote:
> > I have a multi threaded aplication. Should I make all my objects
threadsafe
> > or just those which are really being accessed from different threads?
what
> > are the pros and cons?. Any clue is appriciated.
> >
> > Thanks,
> >   Mark.
> >
>
>
> my advice is to carefully select a minimal number of objects which need
> to be accessed by more than one thread and minimize the number of entry
> points into those objects that can be called on more than one thread.
> this helps you focus on getting the thread safety right in exactly/only
> the places where you know you need it.  don't go overboard on trying to
> make everything threadsafe.  it probably isn't worth it.
>
> also, if you're moving a process onto a background thread, then try to
> separate the objects which must live on that thread from the objects
> that live on other threads.  maybe have only one object that can be
> touched by both threads.  let it be an object that delegates between
> objects on the two threads.  a simple, focused, deliberate MT design is
> much better than one that tries to be multithreaded in general.
>
> an event queue is also a great thread synchronization tool.  it can help
> you keep separate the objects living on different threads.
>
> darin
>

Thanks Darin, this are all good points. I guess the fualt was in my question
I meant to try to understand the difference between using NS_IMPL_ISUPPORTS1
and NS_IMPL_THREADSAFE_ISUPPORTS1. currently I use initialy
NS_IMPL_ISUPPORTS1, and only when an assertion ocoures I change it to the
thread safe version. Do I simply waste my time and should always use
NS_IMPL_THREADSAFE_ISUPPORTS1 ?

Mark.



Reply via email to