Use exclusive RNG lock and replace old RNG

This commit does two things:

1. It allows `withSeed` to call the given function `fun` with a new
rng (which seed has been appropriately set), but at the same time
restores the previous RNG once we finish running the action;

2. It guards the inner action via a mutex so that we can get thread
   safety. This is implemented via `withGlobalRNGLock`.
3 jobs for adinapoli/issue-5 in 0 seconds (queued for 74 minutes and 47 seconds)
Status Job ID Name Coverage
  Test
failed #18118
deps

failed #18119
docs

failed #18120
test

 
Name Stage Failure
failed
test Test There has been a timeout failure or the job got stuck. Check your timeout limits or try again
No job trace
failed
docs Test There has been a timeout failure or the job got stuck. Check your timeout limits or try again
No job trace
failed
deps Test There has been a timeout failure or the job got stuck. Check your timeout limits or try again
No job trace