MantisBT - JANA
View Issue Details
0000335JANAFeature Requestpublic2013-04-03 10:512013-12-13 16:32
0000335: Add user settable reference to JEventLoop
Sometimes there is need to have an object that is thread specific. For example, a random number generator object in mcsmear. The overhead of maintaining this in a list that one then needs to lock a mutex to access every event is unnecessary. Similarly for creating a factory object and accessing the random number generator through that.

If a user-definable reference were added to JEventLoop, one could set it once and then access it at event time without mutex locking.

This could be done in a simple C-style way where the value is kept as a void* and it is up to the user to cast it back to the appropriate form.

Alternatively, one could use templated methods in JEventLoop to record not only the value, but rtti info so that it can be checked upon retrieval (value would be stored as void* in JEventLoop, but converted by template method before returning). This would be safer, but would add a little more overhead. Presumably not as much as mutex locking though. This second method would also allow for more than one type of reference to be stored, though again, for a slight overhead cost.
No tags attached.
Issue History
2013-04-03 10:51davidlNew Issue
2013-12-13 16:32davidlNote Added: 0000581
2013-12-13 16:32davidlStatusnew => resolved
2013-12-13 16:32davidlResolutionopen => fixed
2013-12-13 16:32davidlAssigned To => davidl

2013-12-13 16:32   
This has been committed (with unit test!) and will be in JANA 0.7.0