The first version of thread safety will have decay table thread local as decay models do not guarantee constness in relevant decay functions. After looking bit to the code, there is way to improve this with relatively simple changes, but as they will require touching all decay models it is not trivial to do it quickly. Idea is that EvtDecayBase::make_decay() and EvtDecayBase::decay() functions have to be make constant. I have made local test in which I did part of the work as proof of principle. This work should wait for other big changes to be merged and then transition plan is:
- Move pure virtual method from EvtDecayBase::decay() to EvtDecayIncoherent, EvtDecayProb and EvtDecayAmp classes. This function is called only from make_decay() method in each of these derived classes.
- Create temporary copy of EvtDecayAmp, which should live while we are making transition.
- Change all decay models deriving from EvtDecayAmp to derive from its temporary copy.
- Make EvtDecayBase::getArg() const and propagate effect of it through code. As consequence, drop EvtDecayBase::getStoredArg() and EvtDecayBase::getNStoredArgs() methods as they are not used and not safe as meaning of the index is different to that of getArg().
- In each of the EvtDecayIncoherent, EvtDecayProb and EvtDecayAmp classes modify signature of decay() method to allow them to return relevant values/objects. By moving the method here each class can have different signature. At the same time in each class adapt make_decay() method to new decay() signature. EvtDecayAmp is trivial as at this point nothing will derive from it. EvtDecayProb does not have many models deriving from it and Michal has prototype. EvtDecayIncoherent() has small number of models, but I did not check how difficult it will be to convert.
- In small chunks adapt models based on EvtDecayAmp. Some models might need to go together if they use common infrastructure, but potentially one should be able to split to chunks doable in day or two.
- When nothing derives from temporary copy of EvtDecayAmp, remove temporary copy.
- Make EvtDecayBase::make_decay() const. At this moment, it should affect only 3 classes which define this method.
- If all this succeeds, we should have all we need to remove need of having decay table thread local.