Proper (and thread-safe) implementation for `withSeed`
Fixes #5 (closed).
This MR modifies the original withSeed
such that it will spawn a fresh, independent RNG
which can be passed to the fun
function in order to carry on any required computation. This also adds a mutex to ensure that calls to withSeed
are now thread safe, something very important for Gargantext.
In order to make everything work I had to patch igraph
as the function to set the rng was patched only in the develop branch and we needed the critical bit of being able to return the old RNG when we set a new one. This way we can ensure that withSeed
does any mutation only locally, restoring the old RNG once we get out of the critical section.
@glocqueville would you like to review this?