Skip to content

Commit 38846c3

Browse files
enricosadaKevinRansom
authored andcommitted
use Interlocked.Increment to be thread safe
1 parent 4d30685 commit 38846c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/fsharp/tast.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ open Microsoft.FSharp.Core.CompilerServices
3535
/// Unique name generator for stamps attached to lambdas and object expressions
3636
type Unique = int64
3737
//++GLOBAL MUTABLE STATE
38-
let newUnique = let i = ref 0L in fun () -> i := !i + 1L; !i
38+
let newUnique = let mutable i = 0L in fun () -> System.Threading.Interlocked.Increment(&i)
3939
type Stamp = int64
4040

4141
/// Unique name generator for stamps attached to to val_specs, tycon_specs etc.
4242
//++GLOBAL MUTABLE STATE
43-
let newStamp = let i = ref 0L in fun () -> i := !i + 1L; !i
43+
let newStamp = let mutable i = 0L in fun () -> System.Threading.Interlocked.Increment(&i)
4444

4545
/// A global generator of compiler generated names
4646
// ++GLOBAL MUTABLE STATE

0 commit comments

Comments
 (0)