File tree Expand file tree Collapse file tree 1 file changed +31
-2
lines changed Expand file tree Collapse file tree 1 file changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,42 @@ type env = | NoEnv
1919
2020let FindUnsolvedStackGuardDepth = StackGuard.GetDepthOption " FindUnsolved"
2121
22+ type SyncStackGuard ( maxDepth ) =
23+ let mutable stack = Unchecked.defaultof<_>
24+ let mutable depth = 0
25+ let mutable running = false
26+
27+ let run f =
28+ running <- true
29+ try
30+ stack <- System.Collections.Generic.Stack<_>()
31+ stack.Push f
32+ while stack.Count > 0 do
33+ let f = stack.Pop()
34+ f()
35+ finally
36+ running <- false
37+
38+ let push f =
39+ if not running then run f else stack.Push f
40+
41+ member _.Guard f =
42+ depth <- depth + 1
43+ try
44+ if depth % maxDepth = 0 then
45+ push f
46+ else
47+ f()
48+ finally
49+ depth <- depth - 1
50+
2251/// The environment and collector
2352type cenv =
2453 { g: TcGlobals
2554 amap: Import .ImportMap
2655 denv: DisplayEnv
2756 mutable unsolved: Typars
28- stackGuard: StackGuard }
57+ stackGuard: SyncStackGuard }
2958
3059 override _.ToString () = " <cenv>"
3160
@@ -318,7 +347,7 @@ let UnsolvedTyparsOfModuleDef g amap denv mdef extraAttribs =
318347 amap= amap
319348 denv= denv
320349 unsolved = []
321- stackGuard = StackGuard ( FindUnsolvedStackGuardDepth , " UnsolvedTyparsOfModuleDef " ) }
350+ stackGuard = SyncStackGuard FindUnsolvedStackGuardDepth }
322351 accModuleOrNamespaceDef cenv NoEnv mdef
323352 accAttribs cenv NoEnv extraAttribs
324353 List.rev cenv.unsolved
You can’t perform that action at this time.
0 commit comments