mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
documented the new .gcsafe override pragma
This commit is contained in:
@@ -49,6 +49,21 @@ To disable the GC-safety checking the ``--threadAnalysis:off`` command line
|
||||
switch can be used. This is a temporary workaround to ease the porting effort
|
||||
from old code to the new threading model.
|
||||
|
||||
To override the compiler's gcsafety analysis a ``{.gcsafe.}`` pragma block can
|
||||
be used:
|
||||
|
||||
.. code-block:: nim
|
||||
|
||||
var
|
||||
someGlobal: string = "some string here"
|
||||
perThread {.threadvar.}: string
|
||||
|
||||
proc setPerThread() =
|
||||
{.gcsafe.}:
|
||||
deepCopy(perThread, someGlobal)
|
||||
|
||||
onThreadCreation(setPerThread)
|
||||
|
||||
|
||||
Future directions:
|
||||
|
||||
|
||||
@@ -92,5 +92,4 @@ restrictions / changes:
|
||||
* Every array access has to be provably within bounds. This is called
|
||||
the *bounds check*.
|
||||
* Slices are optimized so that no copy is performed. This optimization is not
|
||||
yet performed for ordinary slices outside of a ``parallel`` section. Slices
|
||||
are also special in that they currently do not support negative indexes!
|
||||
yet performed for ordinary slices outside of a ``parallel`` section.
|
||||
|
||||
Reference in New Issue
Block a user