Task #5340
closedAvoid repeatedly initializing new random generators every time random number is generated
0%
Description
During the refactoring in b8bd5ee965, NFD moved from trying to retrieve a globally shared std::mt19937 object to calling ndn::random::getRandomNumberEngine() instead. This currently yields a new thread local instance of a std::mt19937/RandomNumberEngine object every time it's called. While this is not obviously a functional issue, as we currently generate a new seed sequence every time which should yield a new random number, it is both seemingly inefficient and also makes it more difficult to introduce a seeded RNG for unit testing or trying to otherwise ensure repeatable behavior. It would be sensible to refactor sections of code which rely on this to either use a consistent RandomNumberEngine object local to their instance or to return to maintaining a single common RNG globally.