Standard library / sync/atomic

atomic.Uintptr.Or()

Atomically apply bitwise OR and return the previous value (Go 1.23+). Expected stdout: '12\n15\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Uintptr) Or(mask uintptr) (old uintptr)

Parameters & Attributes

NameTypeDescription
maskuintptrBit mask used by the atomic operation.

Return Value

(old uintptr)

Previous value before OR.

Working Example

Example Snippetgo
package main
import (  "fmt"  "sync/atomic")
func main() { var x atomic.Uintptr; x.Store(12); fmt.Println(x.Or(3)); fmt.Println(x.Load()) }
Go Reference