mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 06:18:51 +00:00
Yrc typos and omissions (#25500)
This commit is contained in:
@@ -68,7 +68,7 @@ type
|
||||
|
||||
proc `=copy`*(x: var Task, y: Task) {.error.}
|
||||
|
||||
const arcLike = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc)
|
||||
const arcLike = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc) or defined(gcYrc)
|
||||
when defined(nimAllowNonVarDestructor) and arcLike:
|
||||
proc `=destroy`*(t: Task) {.inline, gcsafe.} =
|
||||
## Frees the resources allocated for a `Task`.
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
##[
|
||||
Thread support for Nim. Threads allow multiple functions to execute concurrently.
|
||||
|
||||
|
||||
In Nim, threads are a low-level construct and using a library like `malebolgia`, `taskpools` or `weave` is recommended.
|
||||
|
||||
|
||||
When creating a thread, you can pass arguments to it. As Nim's garbage collector does not use atomic references, sharing
|
||||
`ref` and other variables managed by the garbage collector between threads is not supported.
|
||||
Use global variables to do so, or pointers.
|
||||
|
||||
|
||||
Memory allocated using [`sharedAlloc`](./system.html#allocShared.t%2CNatural) can be used and shared between threads.
|
||||
|
||||
To communicate between threads, consider using [channels](./system.html#Channel)
|
||||
@@ -44,7 +44,7 @@ joinThreads(thr)
|
||||
|
||||
deinitLock(L)
|
||||
```
|
||||
|
||||
|
||||
When using a memory management strategy that supports shared heaps like `arc` or `boehm`,
|
||||
you can pass pointer to threads and share memory between them, but the memory must outlive the thread.
|
||||
The default memory management strategy, `orc`, supports this.
|
||||
@@ -52,14 +52,14 @@ The example below is **not valid** for memory management strategies that use loc
|
||||
|
||||
```Nim
|
||||
import locks
|
||||
|
||||
|
||||
var l: Lock
|
||||
|
||||
|
||||
proc threadFunc(obj: ptr seq[int]) {.thread.} =
|
||||
withLock l:
|
||||
for i in 0..<100:
|
||||
obj[].add(obj[].len * obj[].len)
|
||||
|
||||
|
||||
proc threadHandler() =
|
||||
var thr: array[0..4, Thread[ptr seq[int]]]
|
||||
var s = newSeq[int]()
|
||||
@@ -68,7 +68,7 @@ proc threadHandler() =
|
||||
createThread(thr[i], threadFunc, s.addr)
|
||||
joinThreads(thr)
|
||||
echo s
|
||||
|
||||
|
||||
initLock(l)
|
||||
threadHandler()
|
||||
deinitLock(l)
|
||||
@@ -303,5 +303,5 @@ else:
|
||||
proc createThread*(t: var Thread[void], tp: proc () {.thread, nimcall.}) =
|
||||
createThread[void](t, tp)
|
||||
|
||||
when not defined(gcOrc):
|
||||
when not defined(gcOrc) and not defined(gcYrc):
|
||||
include system/threadids
|
||||
|
||||
@@ -25,7 +25,7 @@ when not (defined(cpu16) or defined(cpu8)):
|
||||
bytes: int
|
||||
data: WideCString
|
||||
|
||||
const arcLike = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc)
|
||||
const arcLike = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc) or defined(gcYrc)
|
||||
when defined(nimAllowNonVarDestructor) and arcLike:
|
||||
proc `=destroy`(a: WideCStringObj) =
|
||||
if a.data != nil:
|
||||
|
||||
Reference in New Issue
Block a user