Multithreading: BufferedModule Optimizations
The BufferedModule
implemented to allow sequential processing of events in multithreaded environments still has some minor flaws which we should to overcome eventually. Consider this log:
|13:25:22.917| (TRACE) Running event 1 [ROOTObjectWriter]
|13:25:22.917| (TRACE) (Event 1) [R:ROOTObjectWriter] Buffering event 1
|13:25:22.917| (PRNG) (Event 1) [R:ROOTObjectWriter] Storing PRNG state in event.
|13:25:22.917| (TRACE) (Event 1) [R:ROOTObjectWriter] Writing buffered event 1, 0 left in buffer
|13:25:22.917| (PRNG) (Event 1) [R:ROOTObjectWriter] Restoring PRNG state from event.
|13:25:22.927| (TRACE) (Event 1) [R:ROOTObjectWriter] Writing new objects to tree
This is from a run with a single event. Despite the fact that the buffer is empty, it is first buffered, the PRNG state stored and restored, and the event processed. We should make sure that if the buffer is empty, we simply process the module directly - making sure we're still on the same thread.