put std/threads under the umbrella of nimPreviewSlimSystem (#20711)
* put `std/threads` under the umbrella of `nimPreviewSlimSystem` * add changelog * fixes tests * fixes tests again * fixes tests
This commit is contained in:
parent
fb2ec8d192
commit
e1ddd2d524
13 changed files with 33 additions and 19 deletions
|
|
@ -15,6 +15,7 @@
|
||||||
- `std/formatfloat`
|
- `std/formatfloat`
|
||||||
- `std/objectdollar`
|
- `std/objectdollar`
|
||||||
- `std/widestrs`
|
- `std/widestrs`
|
||||||
|
- `std/threads`
|
||||||
|
|
||||||
In the future, these definitions will be removed from the `system` module,
|
In the future, these definitions will be removed from the `system` module,
|
||||||
and their respective modules will have to be imported to use them.
|
and their respective modules will have to be imported to use them.
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ when not compileOption("threads"):
|
||||||
import cpuinfo, cpuload, locks, os
|
import cpuinfo, cpuload, locks, os
|
||||||
|
|
||||||
when defined(nimPreviewSlimSystem):
|
when defined(nimPreviewSlimSystem):
|
||||||
import std/assertions
|
import std/[assertions, threads]
|
||||||
|
|
||||||
{.push stackTrace:off.}
|
{.push stackTrace:off.}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ import algorithm, math
|
||||||
import std/private/since
|
import std/private/since
|
||||||
|
|
||||||
when defined(nimPreviewSlimSystem):
|
when defined(nimPreviewSlimSystem):
|
||||||
import std/assertions
|
import std/[assertions]
|
||||||
|
|
||||||
include system/inclrtl
|
include system/inclrtl
|
||||||
{.push debugger: off.}
|
{.push debugger: off.}
|
||||||
|
|
|
||||||
|
|
@ -95,16 +95,6 @@ when defined(zephyr):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proc onThreadDestruction*(handler: proc () {.closure, gcsafe, raises: [].}) =
|
|
||||||
## Registers a *thread local* handler that is called at the thread's
|
|
||||||
## destruction.
|
|
||||||
##
|
|
||||||
## A thread is destructed when the `.thread` proc returns
|
|
||||||
## normally or when it raises an exception. Note that unhandled exceptions
|
|
||||||
## in a thread nevertheless cause the whole process to die.
|
|
||||||
nimThreadDestructionHandlers.add handler
|
|
||||||
|
|
||||||
|
|
||||||
{.push stack_trace:off.}
|
{.push stack_trace:off.}
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
proc threadProcWrapper[TArg](closure: pointer): int32 {.stdcall.} =
|
proc threadProcWrapper[TArg](closure: pointer): int32 {.stdcall.} =
|
||||||
|
|
|
||||||
|
|
@ -2093,7 +2093,8 @@ when not defined(js):
|
||||||
when hasThreadSupport:
|
when hasThreadSupport:
|
||||||
when hostOS != "standalone":
|
when hostOS != "standalone":
|
||||||
include system/threadimpl
|
include system/threadimpl
|
||||||
|
when not defined(nimPreviewSlimSystem):
|
||||||
|
{.deprecated: "threads is about to move out of system; use `-d:nimPreviewSlimSystem` and import `std/threads`".}
|
||||||
import std/threads
|
import std/threads
|
||||||
export threads
|
export threads
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,15 @@ template afterThreadRuns() =
|
||||||
for i in countdown(nimThreadDestructionHandlers.len-1, 0):
|
for i in countdown(nimThreadDestructionHandlers.len-1, 0):
|
||||||
nimThreadDestructionHandlers[i]()
|
nimThreadDestructionHandlers[i]()
|
||||||
|
|
||||||
|
proc onThreadDestruction*(handler: proc () {.closure, gcsafe, raises: [].}) =
|
||||||
|
## Registers a *thread local* handler that is called at the thread's
|
||||||
|
## destruction.
|
||||||
|
##
|
||||||
|
## A thread is destructed when the `.thread` proc returns
|
||||||
|
## normally or when it raises an exception. Note that unhandled exceptions
|
||||||
|
## in a thread nevertheless cause the whole process to die.
|
||||||
|
nimThreadDestructionHandlers.add handler
|
||||||
|
|
||||||
when defined(boehmgc):
|
when defined(boehmgc):
|
||||||
type GCStackBaseProc = proc(sb: pointer, t: pointer) {.noconv.}
|
type GCStackBaseProc = proc(sb: pointer, t: pointer) {.noconv.}
|
||||||
proc boehmGC_call_with_stack_base(sbp: GCStackBaseProc, p: pointer)
|
proc boehmGC_call_with_stack_base(sbp: GCStackBaseProc, p: pointer)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import compiler / [options, commands, modules, sem,
|
||||||
idents, modulegraphs, prefixmatches, lineinfos, cmdlinehelper,
|
idents, modulegraphs, prefixmatches, lineinfos, cmdlinehelper,
|
||||||
pathutils]
|
pathutils]
|
||||||
|
|
||||||
|
when defined(nimPreviewSlimSystem):
|
||||||
|
import std/threads
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
import winlean
|
import winlean
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ discard """
|
||||||
|
|
||||||
import std/atomics
|
import std/atomics
|
||||||
|
|
||||||
|
when defined(nimPreviewSlimSystem):
|
||||||
|
import std/[assertions, threads]
|
||||||
|
|
||||||
const MemBlockSize = 256
|
const MemBlockSize = 256
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,10 @@ discard """
|
||||||
import std/envvars
|
import std/envvars
|
||||||
from std/sequtils import toSeq
|
from std/sequtils import toSeq
|
||||||
import stdtest/testutils
|
import stdtest/testutils
|
||||||
import std/assertions
|
import std/[assertions]
|
||||||
|
|
||||||
|
when not defined(js):
|
||||||
|
import std/threads
|
||||||
|
|
||||||
# "LATIN CAPITAL LETTER AE" in UTF-8 (0xc386)
|
# "LATIN CAPITAL LETTER AE" in UTF-8 (0xc386)
|
||||||
const unicodeUtf8 = "\xc3\x86"
|
const unicodeUtf8 = "\xc3\x86"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ discard """
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, net, nativesockets, asyncdispatch
|
import os, net, nativesockets, asyncdispatch
|
||||||
import std/[assertions]
|
import std/[assertions, threads]
|
||||||
|
|
||||||
## Test for net.dial
|
## Test for net.dial
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ discard """
|
||||||
import std/os
|
import std/os
|
||||||
from std/sequtils import toSeq
|
from std/sequtils import toSeq
|
||||||
import stdtest/testutils
|
import stdtest/testutils
|
||||||
import std/assertions
|
|
||||||
|
when defined(nimPreviewSlimSystem):
|
||||||
|
import std/[assertions]
|
||||||
|
|
||||||
# "LATIN CAPITAL LETTER AE" in UTF-8 (0xc386)
|
# "LATIN CAPITAL LETTER AE" in UTF-8 (0xc386)
|
||||||
const unicodeUtf8 = "\xc3\x86"
|
const unicodeUtf8 = "\xc3\x86"
|
||||||
|
|
@ -55,6 +57,8 @@ when defined(windows):
|
||||||
proc c_getenv(env: cstring): cstring {.importc: "getenv", header: "<stdlib.h>".}
|
proc c_getenv(env: cstring): cstring {.importc: "getenv", header: "<stdlib.h>".}
|
||||||
|
|
||||||
when not defined(js) and not defined(nimscript):
|
when not defined(js) and not defined(nimscript):
|
||||||
|
when defined(nimPreviewSlimSystem):
|
||||||
|
import std/threads
|
||||||
block: # bug #18533
|
block: # bug #18533
|
||||||
var thr: Thread[void]
|
var thr: Thread[void]
|
||||||
proc threadFunc {.thread.} = putEnv("foo", "fooVal2")
|
proc threadFunc {.thread.} = putEnv("foo", "fooVal2")
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ discard """
|
||||||
disabled: "openbsd"
|
disabled: "openbsd"
|
||||||
"""
|
"""
|
||||||
# disabled: pending bug #15713
|
# disabled: pending bug #15713
|
||||||
import std/[net, nativesockets, assertions]
|
import std/[net, nativesockets, assertions, threads]
|
||||||
|
|
||||||
when defined(posix): import os, posix
|
when defined(posix): import os, posix
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ Crashes before getting here!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import std/os
|
import std/os
|
||||||
|
import std/threads
|
||||||
|
|
||||||
proc whatever() {.thread, nimcall.} =
|
proc whatever() {.thread, nimcall.} =
|
||||||
echo("TEST")
|
echo("TEST")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue