
Robert Patterson
I have a fairly large simulation code, that I need to get into a state in which I can multi-thread it. One of my problems is a global random number generator state.
I ran into the same problem, and for better or worse I created a singleton to manage the global state (to preempt the anti-singleton crowd: I didn't want to construct if not necessary, wanted easy solution to ODR for header only, not worry about destruction order with singleton dependencies, etc.) I used the loki singleton class, though I am would love a boost version. One thing I really wanted to do was have this singleton theadlocal, but wasn't sure how to do it properly. Here is my simple code, including creation of a MKL stream. I use the reset_all_seeds for simulations when I want to repeat results. http://econtoolkit.com/browser/libraries/trunk/etk/etk/random/random.hpp -Jesse