Gauche icon indicating copy to clipboard operation
Gauche copied to clipboard

Clarify MT safety of random-source

Open shirok opened this issue 2 years ago • 1 comments

Currently our srfi-27 random-source is just a <mersenne-twister> instance, which is not MT-safe. If some library function uses default-random-source implicitly, that function becomes MT-unsafe, which is not desirable.

Choices:

  • Make random-source MT-safe unconditinoally
  • Prominently say default-random-source is MT-unsafe and let every library function mutex it if necessary.
  • Provide MT-safe and MT-unsafe versions of random source, and use MT-safe verion for default-random-source.

shirok avatar Jul 03 '22 00:07 shirok

Made math.mt-random RNG thread-safe by default. Optionally the user can specify no mutex version for speed. Need to extend srfi-27 make-random-source to make no mutex version.

shirok avatar Jul 06 '22 22:07 shirok

We may put off adding option to make-random-source until we see the necessity. Closed for now.

shirok avatar Feb 24 '23 04:02 shirok