mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
clean up the documentation of threads (#21067)
* clean up the documentation of threads * cleanup
This commit is contained in:
@@ -8424,23 +8424,12 @@ This is only useful if the program is compiled as a dynamic library via the
|
||||
`--app:lib`:option: command-line option.
|
||||
|
||||
|
||||
|
||||
Threads
|
||||
=======
|
||||
|
||||
To enable thread support the `--threads:on`:option: command-line switch needs to
|
||||
be used. The [system module](system.html) module then contains several threading primitives.
|
||||
See the [channels](channels_builtin.html) modules
|
||||
for the low-level thread API. There are also high-level parallelism constructs
|
||||
available. See [spawn](manual_experimental.html#parallel-amp-spawn) for
|
||||
The `--threads:on`:option: command-line switch is enabled by default. The [typedthreads module](typedthreads.html) module then contains several threading primitives. See [spawn](manual_experimental.html#parallel-amp-spawn) for
|
||||
further details.
|
||||
|
||||
Nim's memory model for threads is quite different than that of other common
|
||||
programming languages (C, Pascal, Java): Each thread has its own (garbage
|
||||
collected) heap, and sharing of memory is restricted to global variables. This
|
||||
helps to prevent race conditions. GC efficiency is improved quite a lot,
|
||||
because the GC never has to stop other threads and see what they reference.
|
||||
|
||||
The only way to create a thread is via `spawn` or
|
||||
`createThread`. The invoked proc must not use `var` parameters nor must
|
||||
any of its parameters contain a `ref` or `closure` type. This enforces
|
||||
|
||||
@@ -9,12 +9,6 @@
|
||||
|
||||
## Thread support for Nim.
|
||||
##
|
||||
## Nim's memory model for threads is quite different from other common
|
||||
## programming languages (C, Pascal): Each thread has its own
|
||||
## (garbage collected) heap and sharing of memory is restricted. This helps
|
||||
## to prevent race conditions and improves efficiency. See `the manual for
|
||||
## details of this memory model <manual.html#threads>`_.
|
||||
##
|
||||
## Examples
|
||||
## ========
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user