Standard library / sync/atomic

atomic.Uintptr.Add()

Atomically add delta and return the new value. Integer overflow follows the type width. Expected stdout: '15\n15\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Uintptr) Add(delta uintptr) (new uintptr)

Parameters & Attributes

NameTypeDescription
deltauintptrAmount to add; for WaitGroup, change in outstanding task count.

Return Value

(new uintptr)

New value after addition.

Working Example

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