// Copyright 2022 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package atomicimport// A Bool is an atomic boolean value.// The zero value is false.typeBoolstruct { _ noCopyvuint32}// Load atomically loads and returns the value stored in x.func ( *Bool) () bool { returnLoadUint32(&.v) != 0 }// Store atomically stores val into x.func ( *Bool) ( bool) { StoreUint32(&.v, b32()) }// Swap atomically stores new into x and returns the previous value.func ( *Bool) ( bool) ( bool) { returnSwapUint32(&.v, b32()) != 0 }// CompareAndSwap executes the compare-and-swap operation for the boolean value x.func ( *Bool) (, bool) ( bool) {returnCompareAndSwapUint32(&.v, b32(), b32())}// b32 returns a uint32 0 or 1 representing b.func ( bool) uint32 {if {return1 }return0}// For testing *Pointer[T]'s methods can be inlined.// Keep in sync with cmd/compile/internal/test/inl_test.go:TestIntendedInlining.var _ = &Pointer[int]{}// A Pointer is an atomic pointer of type *T. The zero value is a nil *T.typePointer[ any] struct {// Mention *T in a field to disallow conversion between Pointer types. // See go.dev/issue/56603 for more details. // Use *T, not T, to avoid spurious recursive type definition errors. _ [0]* _ noCopyvunsafe.Pointer}// Load atomically loads and returns the value stored in x.func ( *Pointer[]) () * { return (*)(LoadPointer(&.v)) }// Store atomically stores val into x.func ( *Pointer[]) ( *) { StorePointer(&.v, unsafe.Pointer()) }// Swap atomically stores new into x and returns the previous value.func ( *Pointer[]) ( *) ( *) { return (*)(SwapPointer(&.v, unsafe.Pointer())) }// CompareAndSwap executes the compare-and-swap operation for x.func ( *Pointer[]) (, *) ( bool) {returnCompareAndSwapPointer(&.v, unsafe.Pointer(), unsafe.Pointer())}// An Int32 is an atomic int32. The zero value is zero.typeInt32struct { _ noCopyvint32}// Load atomically loads and returns the value stored in x.func ( *Int32) () int32 { returnLoadInt32(&.v) }// Store atomically stores val into x.func ( *Int32) ( int32) { StoreInt32(&.v, ) }// Swap atomically stores new into x and returns the previous value.func ( *Int32) ( int32) ( int32) { returnSwapInt32(&.v, ) }// CompareAndSwap executes the compare-and-swap operation for x.func ( *Int32) (, int32) ( bool) {returnCompareAndSwapInt32(&.v, , )}// Add atomically adds delta to x and returns the new value.func ( *Int32) ( int32) ( int32) { returnAddInt32(&.v, ) }// An Int64 is an atomic int64. The zero value is zero.typeInt64struct { _ noCopy _ align64vint64}// Load atomically loads and returns the value stored in x.func ( *Int64) () int64 { returnLoadInt64(&.v) }// Store atomically stores val into x.func ( *Int64) ( int64) { StoreInt64(&.v, ) }// Swap atomically stores new into x and returns the previous value.func ( *Int64) ( int64) ( int64) { returnSwapInt64(&.v, ) }// CompareAndSwap executes the compare-and-swap operation for x.func ( *Int64) (, int64) ( bool) {returnCompareAndSwapInt64(&.v, , )}// Add atomically adds delta to x and returns the new value.func ( *Int64) ( int64) ( int64) { returnAddInt64(&.v, ) }// A Uint32 is an atomic uint32. The zero value is zero.typeUint32struct { _ noCopyvuint32}// Load atomically loads and returns the value stored in x.func ( *Uint32) () uint32 { returnLoadUint32(&.v) }// Store atomically stores val into x.func ( *Uint32) ( uint32) { StoreUint32(&.v, ) }// Swap atomically stores new into x and returns the previous value.func ( *Uint32) ( uint32) ( uint32) { returnSwapUint32(&.v, ) }// CompareAndSwap executes the compare-and-swap operation for x.func ( *Uint32) (, uint32) ( bool) {returnCompareAndSwapUint32(&.v, , )}// Add atomically adds delta to x and returns the new value.func ( *Uint32) ( uint32) ( uint32) { returnAddUint32(&.v, ) }// A Uint64 is an atomic uint64. The zero value is zero.typeUint64struct { _ noCopy _ align64vuint64}// Load atomically loads and returns the value stored in x.func ( *Uint64) () uint64 { returnLoadUint64(&.v) }// Store atomically stores val into x.func ( *Uint64) ( uint64) { StoreUint64(&.v, ) }// Swap atomically stores new into x and returns the previous value.func ( *Uint64) ( uint64) ( uint64) { returnSwapUint64(&.v, ) }// CompareAndSwap executes the compare-and-swap operation for x.func ( *Uint64) (, uint64) ( bool) {returnCompareAndSwapUint64(&.v, , )}// Add atomically adds delta to x and returns the new value.func ( *Uint64) ( uint64) ( uint64) { returnAddUint64(&.v, ) }// A Uintptr is an atomic uintptr. The zero value is zero.typeUintptrstruct { _ noCopyvuintptr}// Load atomically loads and returns the value stored in x.func ( *Uintptr) () uintptr { returnLoadUintptr(&.v) }// Store atomically stores val into x.func ( *Uintptr) ( uintptr) { StoreUintptr(&.v, ) }// Swap atomically stores new into x and returns the previous value.func ( *Uintptr) ( uintptr) ( uintptr) { returnSwapUintptr(&.v, ) }// CompareAndSwap executes the compare-and-swap operation for x.func ( *Uintptr) (, uintptr) ( bool) {returnCompareAndSwapUintptr(&.v, , )}// Add atomically adds delta to x and returns the new value.func ( *Uintptr) ( uintptr) ( uintptr) { returnAddUintptr(&.v, ) }// noCopy may be added to structs which must not be copied// after the first use.//// See https://golang.org/issues/8005#issuecomment-190753527// for details.//// Note that it must not be embedded, due to the Lock and Unlock methods.typenoCopystruct{}// Lock is a no-op used by -copylocks checker from `go vet`.func (*noCopy) () {}func (*noCopy) () {}// align64 may be added to structs that must be 64-bit aligned.// This struct is recognized by a special case in the compiler// and will not work if copied to any other package.typealign64struct{}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.