.. default-domain:: chpl .. module:: PeekPoke :synopsis: Support for directly accessing an 'atomic' variable's value. PeekPoke ======== **Usage** .. code-block:: chapel use PeekPoke; or .. code-block:: chapel import PeekPoke; Support for directly accessing an 'atomic' variable's value. .. warning:: This module is unstable and the API is likely to change over time. This module provides `peek()` and `poke()` operations on atomics. `peek()` and `poke()` are non-atomic read and write operations. They can provide a performance improvement when local reads/writes are performed and atomicity is not required. For example they can be used to initialize an array of atomics or perform a reduction when no concurrent updates are occurring. .. code-block:: chapel use BlockDist, PeekPoke; const space = {1..1000}; const D = space dmapped blockDist(space); var A: [D] atomic int; forall i in D do A[i].poke(i); const sum = + reduce A.peek(); writeln(sum); // 500500 .. method:: proc AtomicBool.peek(): bool Non-atomically reads the stored value. .. method:: proc ref AtomicBool.poke(val: bool): void Non-atomically writes `val`. .. method:: proc AtomicT.peek(): valType Non-atomically reads the stored value. .. method:: proc ref AtomicT.poke(val: valType): void Non-atomically writes `val`.