Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sharedlists/sharedtables modules need threads option #18185

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/pure/collections/sharedlist.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
##
## Unstable API.


when not compileOption("threads") and not defined(nimdoc):
{.error: "SharedList requires --threads:on option.".}

{.push stackTrace: off.}

import
Expand Down
8 changes: 6 additions & 2 deletions lib/pure/collections/sharedtables.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
##
## Unstable API.


when not compileOption("threads") and not defined(nimdoc):
{.error: "SharedTables requires --threads:on option.".}

import
hashes, math, locks

Expand Down Expand Up @@ -62,7 +66,7 @@ template withValue*[A, B](t: var SharedTable[A, B], key: A,
value, body: untyped) =
## Retrieves the value at `t[key]`.
## `value` can be modified in the scope of the `withValue` call.
runnableExamples:
runnableExamples("--threads:on"):
var table: SharedTable[string, string]
init(table)

Expand Down Expand Up @@ -96,7 +100,7 @@ template withValue*[A, B](t: var SharedTable[A, B], key: A,
value, body1, body2: untyped) =
## Retrieves the value at `t[key]`.
## `value` can be modified in the scope of the `withValue` call.
runnableExamples:
runnableExamples("--threads:on"):
var table: SharedTable[string, string]
init(table)

Expand Down
4 changes: 2 additions & 2 deletions tests/js/tstdlib_imports.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import std/[

# Collections:
critbits, deques, heapqueue, intsets, lists, options, sets,
sharedlist, tables,
# fails: sharedtables
tables,
# fails: sharedlist, sharedtables

# Strings:
cstrutils, editdistance, wordwrap, parseutils, ropes,
Expand Down
7 changes: 6 additions & 1 deletion tests/stdlib/tsharedlist.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import sharedlist
discard """
matrix: "--threads:on"
"""


import std/[sharedlist]

var
list: SharedList[int]
Expand Down
2 changes: 1 addition & 1 deletion tests/system/tuse_version.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
cmd: "nim c --useVersion:1.0 -r $file"
cmd: "nim c --useVersion:1.0 -r --threads:on $file"
output: "1.0.100"
"""

Expand Down
4 changes: 2 additions & 2 deletions tests/test_nimscript.nims
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import std/[

# Collections:
critbits, deques, heapqueue, intsets, lists, options, sets,
sharedlist, tables,
# fails: sharedtables
tables,
# fails: sharedlist, sharedtables

# Strings:
editdistance, wordwrap, parseutils, ropes,
Expand Down