[Insight-developers] thread safety question

Lydia Ng lng@insightful.com
Thu, 15 Feb 2001 22:52:42 -0800


Hi,

I have a couple of questions on the issue of thread safety.

My general questions are:
- What are our design specifications in terms of thread safety? 
- What is the group consensus in terms of which types of
  objects need to be thread safe?

I have a more specific question:

Suppose I have a ImageFunction subclass, say FooFunction.
I have an algorithm which creates an instance of FooFunction
and calls the Evaluate() method many times (O(10^6)) per iteration.
Each evaluation requires some scratch variables. Currently, I
have been using member variables as scratch memory to avoid
the overhead of allocating and deallocating them each time
I call Evaluate().

It was brought to my attention that this may not be a good thing
to do as it not thread safe.

My view is that I see ImageFunction as lightweight utility classes
like Iterators and I would not expect the same instance of
FooFunction to be used across threads. Is this thinking wrong?

Lydia