L
Lew
getCurrParameterBlock() returns a reference, simply a global
ParameterBlock, which can be set by other methods. First, the
ParameterBlock defines the parameters, which are quite identical for
each image, so it isn't a problem if this variable is global. Second
an image pi is added wich must be local because of thread savety.
So, with the first line
ParameterBlock pb; //pb is local
pb is a pointer that does not yet point to anything (not even 'null').
then with
pb = IqmTools.getCurrParameterBlock(); //pb isn't local any more,
it's global?, really?
That depends. What gets returned by the method? If it's a pointer to
a parameter block that other modules or threads also point to, then
that block instance is shared.
Consider this. Suppose you and a co-worker are both pointing to the
same desk. How many pointers are there? How many desks?
// a local image is added but pb is global? I'm not really convinced
at this point.
pb.addSource(pi);
If 'pb' points to the same parameter block as someone else's pointer,
then both pointers point to a parameter block that has the same image
as a "source".
I'll try the clone method for a thread save [sic] copy. I'll post the
results.
'clone()' is probably not the answer. You'd be better off using the
'new' operator for most use cases. 'clone()' introduces its own
problems.