# std/isolation

Theme:

- Manual
- Standard library
- Index
- Compiler docs
- Fusion docs
- devel, stable

Search:
Source Edit

This module implements the `Isolated[T]` type for safe construction of isolated subgraphs that can be passed efficiently to different channels and threads.

Warning: This module is experimental and its interface may change.

# Types

    Isolated[T] {.sendable.} = object

  Isolated data can only be moved, not copied. Source Edit

# Procs

    proc `=copy`[T](dest: var Isolated[T]; src: Isolated[T]) {.error.}

  Source Edit

    proc `=destroy`[T](dest: var Isolated[T]) {.inline, ...raises: [].}

  Source Edit

    proc `=sink`[T](dest: var Isolated[T]; src: Isolated[T]) {.inline.}

  Source Edit

    func extract[T](src: var Isolated[T]): T

  Returns the internal value of `src`. The value is moved from `src`. Source Edit

    func isolate[T](value: sink T): Isolated[T] {.magic: "Isolate", ...raises: [],
        tags: [], forbids: [].}

  Creates an isolated subgraph from the expression `value`. Isolation is checked at compile time.

  Please read https://github.com/nim-lang/RFCs/issues/244 for more details.

  Source Edit

    func unsafeIsolate[T](value: sink T): Isolated[T]

  Creates an isolated subgraph from the expression `value`.
  Warning: The proc doesn't check whether `value` is isolated.
  Source Edit