Skip to content

Key

Stores a strand-local value.

Constructor

Key()

Creates a new strand-local key.

let key = strand.Key()

Fields

value

Gets or sets the value associated with this key in the current strand.

Defaults to nil when the key has not been set in the current strand.

let key = strand.Key()
assert_eq $key.value nil

key.value = "parent"
assert_eq $key.value "parent"

let results = strand.fork
  do
    assert_eq $key.value "parent"
    key.value = "child"
    key.value

assert_eq $results (Tuple(["child"]))
assert_eq $key.value "parent"
Open in playground