diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-03-23 11:11:48 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-23 19:49:25 +0000 |
commit | e7dbef922a2fc73469f12c520bcc1af54fe038fb (patch) | |
tree | 02c18e1d1c9d0d85914626f66ace24a79f892e79 /basic/source | |
parent | 462ebbd10bd537f42104fe991a0aeebcd563f178 (diff) |
rtl::Static to thread-safe-static
Change-Id: Ife02e6d2be3ebfbb08522ab0183ef4aa31a99e19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149415
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source')
-rw-r--r-- | basic/source/runtime/methods.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 2835a4915392..986860c935a3 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -3431,7 +3431,11 @@ struct RandomNumberGenerator } }; -class theRandomNumberGenerator : public rtl::Static<RandomNumberGenerator, theRandomNumberGenerator> {}; +RandomNumberGenerator& theRandomNumberGenerator() +{ + static RandomNumberGenerator theGenerator; + return theGenerator; +} } @@ -3444,7 +3448,7 @@ void SbRtl_Randomize(StarBASIC *, SbxArray & rPar, bool) if (rPar.Count() == 2) { int nSeed = static_cast<int>(rPar.Get(1)->GetInteger()); - theRandomNumberGenerator::get().global_rng.seed(nSeed); + theRandomNumberGenerator().global_rng.seed(nSeed); } // without parameter, no need to do anything - RNG is seeded at first use } @@ -3458,7 +3462,7 @@ void SbRtl_Rnd(StarBASIC *, SbxArray & rPar, bool) else { std::uniform_real_distribution<double> dist(0.0, 1.0); - double const tmp(dist(theRandomNumberGenerator::get().global_rng)); + double const tmp(dist(theRandomNumberGenerator().global_rng)); rPar.Get(0)->PutDouble(tmp); } } |