patches for stricteffects (#24)

This commit is contained in:
ringabout 2022-11-22 01:02:17 +08:00 committed by GitHub
parent 17e8479a74
commit 74ae5a71fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -17,7 +17,7 @@ when not defined(windows):
var tp: Taskpool var tp: Taskpool
proc dfs(depth, breadth: int): uint32 = proc dfs(depth, breadth: int): uint32 {.gcsafe.} =
if depth == 0: if depth == 0:
return 1 return 1

View File

@ -133,7 +133,7 @@ var
odd: Matrix[float64] odd: Matrix[float64]
even: Matrix[float64] even: Matrix[float64]
proc heat(m: Matrix[float64], il, iu: int32): bool {.discardable.}= proc heat(m: Matrix[float64], il, iu: int32): bool {.discardable, gcsafe.}=
# TODO to allow awaiting `heat` we return a dummy bool # TODO to allow awaiting `heat` we return a dummy bool
# The parallel spawns are updating the same matrix cells otherwise # The parallel spawns are updating the same matrix cells otherwise
if iu - il > 1: if iu - il > 1:
@ -160,7 +160,7 @@ proc heat(m: Matrix[float64], il, iu: int32): bool {.discardable.}=
row[j] = f(xu + i*dx, yu + j*dy) row[j] = f(xu + i*dx, yu + j*dy)
row[ny - 1] = randb(xu + i*dx, 0) row[ny - 1] = randb(xu + i*dx, 0)
proc diffuse(output: Matrix[float64], input: Matrix[float64], il, iu: int32, t: float64): bool {.discardable.} = proc diffuse(output: Matrix[float64], input: Matrix[float64], il, iu: int32, t: float64): bool {.discardable, gcsafe.} =
# TODO to allow awaiting `diffuse` we return a dummy bool # TODO to allow awaiting `diffuse` we return a dummy bool
# The parallel spawns are updating the same matrix cells otherwise # The parallel spawns are updating the same matrix cells otherwise
if iu - il > 1: if iu - il > 1:

View File

@ -111,7 +111,7 @@ proc nqueens_ser(n, j: int32, a: CharArray): int32 =
if isValid(j+1, a): if isValid(j+1, a):
result += nqueens_ser(n, j+1, a) result += nqueens_ser(n, j+1, a)
proc nqueens_par(n, j: int32, a: CharArray): int32 = proc nqueens_par(n, j: int32, a: CharArray): int32 {.gcsafe.} =
if n == j: if n == j:
# Good solution, count it # Good solution, count it

View File

@ -21,7 +21,7 @@ block: # Async/Await
var tp: Taskpool var tp: Taskpool
proc asyncFib(n: int): int = proc asyncFib(n: int): int {.gcsafe.} =
if n < 2: if n < 2:
return n return n