Documentation
¶
Overview ¶
Copyright (c) 2024 RethinkDNS and its authors.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (c) 2024 RethinkDNS and its authors.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Index ¶
- Constants
- Variables
- func All[T any](who string, timeout time.Duration, fs ...WorkCtx[T]) ([]T, []error)
- func Alloc() *[]byte
- func Alloc16() *[]byte
- func AllocRegion(size int) *[]byte
- func Await(f func(), until time.Duration) (awaited bool)
- func BuildInfo() string
- func ChooseOne[T any](c []T) (zz T)
- func Close(cs ...io.Closer)
- func CloseConn(cs ...MinConn)
- func CloseFD(fd int)
- func CloseFile(f *os.File)
- func CloseOp(c io.Closer, op CloserOp)
- func CloseTCP(c *net.TCPConn)
- func CloseTCPRead(r TCPConn)
- func CloseTCPWrite(w TCPConn)
- func CloseUDP(c *net.UDPConn)
- func CopyUniq[T comparable](a ...[]T) (out []T)
- func DisableKeepAlive(c MinConn) (done bool)
- func DumpRecorder(onConsole bool) (got bool, b bytes.Buffer)
- func Echo(pc net.PacketConn, pkt []byte, dst net.Addr, v4 bool) (reply []byte, from net.Addr, err error)
- func EitherOr(either <-chan struct{}, or Callback, until time.Duration) (esc bool)
- func FilterLeft[T any](arr []T, test TestFn[T]) (out []T)
- func First[T any](who string, overallTimeout time.Duration, fs ...WorkCtx[T]) (zz T, idx int)
- func FirstOf[T any](c []T) (zz T)
- func FmtBytes(val uint64) string
- func FmtMillis(ms int64) string
- func FmtPeriod(d time.Duration) string
- func FmtSecs(s int64) string
- func FmtTimeAsPeriod(t time.Time) string
- func FmtTimeNs(ns uint64) string
- func FmtUnixEpochAsPeriod(secs int64) string
- func FmtUnixMillisAsPeriod(ms int64) string
- func FmtUnixMillisAsTimestamp(ms int64) string
- func Gg(who string, f func(), cb func())
- func Gif(cond bool, who string, f func())
- func Go(who string, f func())
- func Go1[T any](who string, f func(T), arg T)
- func Go2[T0 any, T1 any](who string, f func(T0, T1), a0 T0, a1 T1)
- func Grx[T any](who string, f WorkCtx[T], d time.Duration) (zz T, completed bool)
- func Gx(who string, f func())
- func IP2Cidr(ippOrCidr string) (*net.IPNet, error)
- func IP2Cidr2(ippOrCidr string) (zz netip.Prefix, err error)
- func IsAll[T any](arr []T, test TestFn[T]) bool
- func IsAny[T any](arr []T, test TestFn[T]) bool
- func IsNil(x any) bool
- func IsNotNil(x any) bool
- func IsZero(x any) bool
- func JoinErr(errs ...error) error
- func LOB() *[]byte
- func Loc(x any) uintptr
- func LocEq(a, b any) bool
- func Map[T, U any](arr []T, transform func(T) U) (out []U)
- func Nano2Sec(ns uint64) int64
- func NewConnMap() *cm
- func NewP2QuantileEstimator(ctx context.Context, samples int64, probability float64) *p2
- func NewP50Estimator(ctx context.Context) *p2
- func OneErr(errs ...error) error
- func Periodic(id string, pctx context.Context, d time.Duration, f func()) context.Context
- func Ping(pc net.PacketConn, ipp netip.AddrPort) (ok bool, rtt time.Duration, err error)
- func Pipe(dst io.Writer, src io.Reader) (int64, error)
- func Race[T any](who string, timeout time.Duration, fs ...WorkCtx[T]) (zz T, fidx int, errs error)
- func RandomIPFromPrefix(cidr netip.Prefix) (netip.Addr, error)
- func Record(start bool) (recording bool, err error)
- func Recording() bool
- func Recover(code ExitCode, aux any) (didpanic bool)
- func RecoverFn(aux string, fn Finally) (didpanic bool)
- func Recycle(b *[]byte) bool
- func SetKeepAliveConfig(c MinConn) bool
- func SetKeepAliveConfigSockOpt(c MinConn, args ...int) (ok bool)
- func SetTimeoutSockOpt(c MinConn, timeoutms int) bool
- func ShuffleInPlace[T any](c []T) []T
- func SigFin(id string, f func()) <-chan struct{}
- func Sort[T any](arr []T, less func(a, b T) int) []T
- func Stream(dst io.Writer, src io.Reader) (written int64, err error)
- func TlsSessionCache() tls.ClientSessionCache
- func TrimmedClone(pkt *stack.PacketBuffer) *stack.PacketBuffer
- func TypeEq(a, b any) bool
- func UniqErr(errs ...error) error
- func UniqStr(s string) string
- func UniqStringer(s fmt.Stringer) string
- func Version() string
- func WithElem[T comparable](s []T, add T) []T
- func WithoutElem[T comparable](arr []T, elem T) (out []T)
- func WithoutNils[T any](arr []T) (out []T)
- type Barrier
- type ByteWriter
- type Callback
- type CheckIn
- type CloserOp
- type ConnMapper
- type ConnPool
- type ControlConn
- type DuplexCloser
- type DuplexConn
- type ExitCode
- type ExpMap
- func (m *ExpMap[P, Q]) Alive(key P) bool
- func (m *ExpMap[P, Q]) Clear() int
- func (m *ExpMap[P, Q]) Delete(key P)
- func (m *ExpMap[P, Q]) Get(key P) uint32
- func (m *ExpMap[P, Q]) K(key P, value Q, expiry time.Duration) uint32
- func (m *ExpMap[P, Q]) Len() int
- func (m *ExpMap[P, Q]) Set(key P, expiry time.Duration) uint32
- func (m *ExpMap[P, Q]) V(key P) (zz Q, fresh bool)
- type Finally
- type Flow
- type FlowFunc
- type FlowOn
- type Hangover
- type ICMPConn
- type Job
- type JobShift
- type KeepAliveConn
- type MinConn
- type MultConnPool
- type P2QuantileEstimator
- type PcapHeader
- type PcapPacket
- type PoolableConn
- type ReadRetrierConn
- type RetrierConn
- type RollingWaitGroup
- type Scheduler
- func (s *Scheduler) At(id string, t time.Time, f Job) context.Context
- func (s *Scheduler) Clear(ids ...string) int
- func (s *Scheduler) Retry(id string, t time.Time, f Job, retries uint16, multiplier time.Duration) context.Context
- func (s *Scheduler) Shift(id string, t time.Time, f JobShift) context.Context
- type Sieve
- type Sieve2K
- type SigCond
- type TCPConn
- type TestFn
- type UDPConn
- type V
- type Volatile
- type WeakRef
- type Work
- type Work1
- type WorkCtx
- type WriteRetrierConn
Constants ¶
const ( // Anew is the value returned by Barrier.Do when the function was // executed and its results are stored in the Barrier. Anew = iota // results are already stored in the Barrier. Shared )
const ( // B524288 is slab of size 512k B524288 = 512 * 1024 // B65536 is slab of size 64k B65536 = 64 * 1024 // B32768 is slab of size 32k B32768 = 32 * 1024 // B16384 is slab of size 16k B16384 = 16 * 1024 // B8192 is slab of size 8k B8192 = 8 * 1024 // B4096 is slab of size 4k B4096 = 4 * 1024 // B2048 is slab of size 2k; also the min B2048 = 2 * 1024 // BMAX is the largest pooled slab size BMAX = B524288 )
const ( UNKNOWN_UID = -1 UNKNOWN_UID_STR = "-1" DNS_UID_STR = "1051" UNSUPPORTED_NETWORK = -1 )
const Nobody = uintptr(0) // nobody
Variables ¶
var ( // Commit set at link time by git rev-parse --short HEAD Commit string // Date set at link time by date -u +'%Y%m%d%H%M%S' Date string )
var UndelegatedDomains = []string{}/* 144 elements not displayed */
Functions ¶
func AllocRegion ¶
AllocRegion returns a truncated byte slice at least size big
func CopyUniq ¶
func CopyUniq[T comparable](a ...[]T) (out []T)
flattens and returns a (stable) copy with dups removed, if any. go.dev/play/p/OzJs4s6XvQe
func DisableKeepAlive ¶
func DumpRecorder ¶
Logs flight recorder to console if onConsole is true. The returned value b contains recorded bytes when got is true.
func FilterLeft ¶
func FmtTimeAsPeriod ¶
func FmtUnixEpochAsPeriod ¶
func FmtUnixMillisAsPeriod ¶
func Gg ¶
func Gg(who string, f func(), cb func())
Gg runs f in a goroutine, recovers from any panics if any; then calls cb in a separate goroutine, and recovers from any panics.
func IsNil ¶
IsNil reports whether x is nil if its Chan, Func, Map, Pointer, UnsafePointer, Interface, and Slice; may panic or return false if x is not addressable
func NewConnMap ¶
func NewConnMap() *cm
func NewP2QuantileEstimator ¶
NewP90Estimator returns a new estimator with percentile p.
func NewP50Estimator ¶
NewP50Estimator returns a new P50 (median) estimator.
func Pipe ¶
Pipe reads data from src to dst, and returns the number of bytes copied. Prefers src.WriteTo(dst) and dst.ReadFrom(src) if available. Otherwise, it uses core.Stream.
func Race ¶
Race runs all the functions in fs concurrently and returns the first non-error result. Returned values are the result, the index of the function that returned the result, and any errors. If all functions return an error, the accumulation of it is returned. Panicking functions are considered as returning an error. If the timeout is reached, errTimeout is returned. Note that, zero value result could be returned if at least one function returns that without any error. go.dev/play/p/GVW-dXcZORr
func RandomIPFromPrefix ¶
RandomIPFromPrefix returns a random IP from the provided CIDR prefix. Supports IPv4 and IPv6. Does not support mapped inputs.
func Recover ¶
Recover must be called as a defered function, and must be the first defer called at the start of a new goroutine.
func RecoverFn ¶
fn is called in a separate goroutine, if a panic is recovered. RecoverFn must be called as a defered function, and must be the first defer called at the start of a new goroutine.
func SetKeepAliveConfig ¶
func SetKeepAliveConfigSockOpt ¶
SetKeepAliveConfigSockOpt sets for a TCP connection, SO_KEEPALIVE, TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT, TCP_USER_TIMEOUT. args is optional, and should be in the order of idle, interval, count.
func SetTimeoutSockOpt ¶
func ShuffleInPlace ¶
func ShuffleInPlace[T any](c []T) []T
func SigFin ¶
func SigFin(id string, f func()) <-chan struct{}
SigFin runs f in a goroutine and returns a channel that is closed when f returns.
func Sort ¶
sorts arr x in ascending order. less(a, b) < 0 when a < b, less(a, b) > 0 when a > b, and less(a, b) == 0 when a == b.
func Stream ¶
Stream reads data from src in to dst until error, and returns the no. of bytes read. Internally, it bypasses io.ReaderFrom and io.WriterTo but uses io.CopyBuffer, recycling buffers from a global pool.
func TlsSessionCache ¶
func TlsSessionCache() tls.ClientSessionCache
func TrimmedClone ¶
func TrimmedClone(pkt *stack.PacketBuffer) *stack.PacketBuffer
trimmedClone clones the packet buffer to not modify the original. It trims anything before the network header.
func UniqStringer ¶
func WithElem ¶
func WithElem[T comparable](s []T, add T) []T
WithElem returns arr with elem added to it.
func WithoutElem ¶
func WithoutElem[T comparable](arr []T, elem T) (out []T)
WithoutElem returns arr (may be a copy) removing all occurrences of elem.
func WithoutNils ¶
func WithoutNils[T any](arr []T) (out []T)
Types ¶
type Barrier ¶
type Barrier[T any, K comparable] struct { // contains filtered or unexported fields }
Barrier represents a class of work and forms a namespace in which units of work can be executed with duplicate suppression.
func NewBarrier ¶
NewBarrier returns a new Barrier with the given time-to-live for completed Vs.
func NewBarrier2 ¶
func NewBarrier2[T any, K comparable](ttl, neg time.Duration) *Barrier[T, K]
NewBarrier2 returns a new Barrier with the time-to-lives for completed Vs (ttl) and errored Vs (neg).
func NewKeyedBarrier ¶
func NewKeyedBarrier[T any, K comparable](ttl time.Duration) *Barrier[T, K]
func (*Barrier[T, K]) Do ¶
Do executes and returns the results of the given function, making sure that only one execution is in-flight for a given key at a time. If a duplicate comes in, the duplicate caller waits for the original to complete and receives the same results.
type ByteWriter ¶
type ByteWriter struct {
// contains filtered or unexported fields
}
func (*ByteWriter) Bytes ¶
func (w *ByteWriter) Bytes() []byte
func (*ByteWriter) Close ¶
func (w *ByteWriter) Close() error
func (*ByteWriter) Copy ¶
func (w *ByteWriter) Copy() []byte
func (*ByteWriter) Dup ¶
func (w *ByteWriter) Dup() ByteWriter
func (*ByteWriter) Len ¶
func (w *ByteWriter) Len() int
func (*ByteWriter) Reset ¶
func (w *ByteWriter) Reset()
type ConnMapper ¶
type ConnMapper interface {
// Clear untracks all conns.
Clear() []string
// Track maps x[] to cid.
Track(cid, uid, pid string, x ...MinConn) int
// Get returns a conn mapped to connection id, cid.
Get(cid string) []MinConn
// GetAll returns all conns mapped to pid or uid.
GetAll(uidOrPid string) []MinConn
// Untrack closes all conns with connection id, cid.
Untrack(cid string) int
// UntrackBatch untracks one cid at a time.
UntrackBatch(cidsOrUidsOrPids []string) []string
// Len returns the number of tracked conns.
Len() int
// String returns a string repr of all tracked conns.
String() string
}
type ConnPool ¶
type ConnPool[T comparable] struct { // contains filtered or unexported fields }
github.com/redis/go-redis/blob/d9eeed13/internal/pool/pool.go
func NewConnPool ¶
func NewConnPool[T comparable](ctx context.Context, id T) *ConnPool[T]
NewConnPool creates a new conn pool with preset capacity and ttl.
type ControlConn ¶
type ControlConn = PoolableConn
type DuplexConn ¶
type DuplexConn interface {
TCPConn
DuplexCloser
PoolableConn
KeepAliveConn
}
DuplexConn represents a bidirectional stream socket.
type ExitCode ¶
type ExitCode int
const DontExit ExitCode = 0
DontExit is a special code that can be passed to Recover to indicate that the process should not exit after recovering from a panic.
const Exit11 ExitCode = 11
An exit code of 11 keeps us out of the way of the detailed exitcodes from plan, and also happens to be the same code as SIGSEGV which is roughly the same type of condition that causes most panics.
type ExpMap ¶
type ExpMap[P comparable, Q any] struct { sync.Mutex // guards ExpMap. // contains filtered or unexported fields }
ExpMap holds expiring keys and read hits.
func NewExpiringMap ¶
func NewExpiringMap[P comparable, Q any](ctx context.Context) *ExpMap[P, Q]
NewExpiringMap returns a new ExpMap with min lifetime of 0.
func NewExpiringMapLifetime ¶
func (*ExpMap[P, Q]) K ¶
Set sets the (value, expiry) for the given key and returns the number of hits. expiry must be greater than the minimum lifetime.
type Flow ¶
type Flow[T any] struct { // contains filtered or unexported fields }
func NewForeverFlow ¶
func (*Flow[T]) CompareAndSwap ¶
type Hangover ¶
type Hangover struct {
// contains filtered or unexported fields
}
func NewHangover ¶
func NewHangover() *Hangover
type ICMPConn ¶
type ICMPConn interface {
ControlConn // see: ping.go:setttl
net.PacketConn
}
type KeepAliveConn ¶
KeepAliveConn supports keep-alive probes.
type MinConn ¶
type MinConn interface {
io.Closer
LocalAddr() net.Addr
// Doc copied from net.Conn:
// SetDeadline sets the read and write deadlines associated
// with the connection. It is equivalent to calling both
// SetReadDeadline and SetWriteDeadline.
//
// A deadline is an absolute time after which I/O operations
// fail instead of blocking. The deadline applies to all future
// and pending I/O, not just the immediately following call to
// Read or Write. After a deadline has been exceeded, the
// connection can be refreshed by setting a deadline in the future.
//
// If the deadline is exceeded a call to Read or Write or to other
// I/O methods will return an error that wraps os.ErrDeadlineExceeded.
// This can be tested using errors.Is(err, os.ErrDeadlineExceeded).
// The error's Timeout method will return true, but note that there
// are other possible errors for which the Timeout method will
// return true even if the deadline has not been exceeded.
//
// An idle timeout can be implemented by repeatedly extending
// the deadline after successful Read or Write calls.
//
// A zero value for t means I/O operations will not time out.
SetDeadline(t time.Time) error
// Doc copied from net.Conn:
// SetReadDeadline sets the deadline for future Read calls
// and any currently-blocked Read call.
// A zero value for t means Read will not time out.
SetReadDeadline(t time.Time) error
// Doc copied from net.Conn:
// SetWriteDeadline sets the deadline for future Write calls
// and any currently-blocked Write call.
// Even if write times out, it may return n > 0, indicating that
// some of the data was successfully written.
// A zero value for t means Write will not time out.
SetWriteDeadline(t time.Time) error
}
MinConn is a minimal connection interface that is a subset of both net.Conn and net.PacketConn.
type MultConnPool ¶
type MultConnPool[T comparable] struct { // contains filtered or unexported fields }
func NewMultConnPool ¶
func NewMultConnPool[T comparable](ctx context.Context) *MultConnPool[T]
NewMultConnPool creates a new multi connection-pool.
func (*MultConnPool[T]) Get ¶
func (m *MultConnPool[T]) Get(id T) net.Conn
Get returns a conn from the pool[id], if available.
type P2QuantileEstimator ¶
type P2QuantileEstimator interface {
// Add a sample to the estimator.
Add(float64)
// Get the estimation for p.
Get() int64
// Get the percentile, p.
P() float64
}
P2QuantileEstimator is an interface for the P2 quantile estimator.
type PcapHeader ¶
type PcapPacket ¶
type PcapPacket struct {
Timestamp time.Time
Packet *stack.PacketBuffer
MaxCaptureLen int
}
func (*PcapPacket) MarshalBinary ¶
func (p *PcapPacket) MarshalBinary() ([]byte, error)
type RetrierConn ¶
type RetrierConn interface {
ReadRetrierConn
WriteRetrierConn
}
type RollingWaitGroup ¶
type RollingWaitGroup struct {
// contains filtered or unexported fields
}
RollingWaitGroup is like sync.WaitGroup but rolls over to a new internal WaitGroup after each Wait() call. This allows reuse of the same RollingWaitGroup for multiple wait cycles, without having to create a new instance each time. Each Add() call returns a generation number that must be passed to the corresponding Done() call. This ensures that Done() calls from a previous generation do not affect the current generation.
func (*RollingWaitGroup) Add ¶
func (m *RollingWaitGroup) Add(delta uint16) bool
Add adds non-negative delta to the current generation WaitGroup counter.
func (*RollingWaitGroup) Done ¶
func (m *RollingWaitGroup) Done()
Done decrements the WaitGroup counter for the current generation by one.
func (*RollingWaitGroup) Wait ¶
func (m *RollingWaitGroup) Wait()
Wait blocks until the WaitGroup counter for the current generation is zero. It then rolls over to a new generation. It is safe to call Wait concurrently with Add and Done.
func (*RollingWaitGroup) WouldWait ¶
func (m *RollingWaitGroup) WouldWait() bool
WouldWait returns true if the WaitGroup counter for the current generation is non-zero.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
type Sieve ¶
type Sieve[K comparable, V any] struct { // contains filtered or unexported fields }
Sieve is a thread-safe map with expiring keys.
func (*Sieve[K, V]) Del ¶
func (s *Sieve[K, V]) Del(k K)
Del removes the element with the given key from the sieve.
func (*Sieve[K, V]) Get ¶
Get returns the value associated with the given key, and a boolean indicating whether the key was found.
type Sieve2K ¶
type Sieve2K[K1, K2 comparable, V any] struct { // contains filtered or unexported fields }
Sieve2K is a map of expiring maps. The outer map is keyed to K1, while the inner expiring maps are keyed to K2.
func NewSieve2K ¶
func NewSieve2K[K1, K2 comparable, V any](ctx context.Context, dur time.Duration) *Sieve2K[K1, K2, V]
NewSieve2K returns a new Sieve2K with keys expiring after lifetime.
func (*Sieve2K[K1, K2, V]) Del ¶
func (s *Sieve2K[K1, K2, V]) Del(k1 K1, k2 K2)
Del removes the element with the given key from the sieve.
func (*Sieve2K[K1, K2, V]) Get ¶
Get returns the value associated with the given key, and a boolean indicating whether the key was found.
type SigCond ¶
type SigCond struct {
// contains filtered or unexported fields
}
A "signalable boolean". This is like sync.Cond but light-weight and only allows a single state transition: false -> true. Once signalled, it stays signalled forever. Waiters wait until the condition is true. This is useful for one-time events like "the connection is closed".
It is safe for multiple goroutines to call Signal concurrently; only one will succeed and the others will be no-ops.
It is safe for multiple goroutines to call Wait concurrently; all will be woken when the condition is signalled.
It is safe for one goroutine to call Signal while other goroutines are calling Wait.
It is not safe to reuse a SigCond after signalling it.
func NewSigCond ¶
func NewSigCond() *SigCond
type TCPConn ¶
type TCPConn interface {
DuplexCloser
// RemoteAddr returns the destination network address.
RemoteAddr() net.Addr
// LocalAddr returns the local client network address.
LocalAddr() net.Addr
// confirms to protect.Conn
Write([]byte) (int, error)
Read([]byte) (int, error)
// Implements MinConn and net.Conn
SetDeadline(time.Time) error
SetReadDeadline(time.Time) error
SetWriteDeadline(time.Time) error
}
TCPConn abstracts a TCP connection coming from TUN. This connection should be handled by a registered TCP proxy handler.
type UDPConn ¶
type UDPConn interface {
io.Closer
// LocalAddr returns the local client network address.
LocalAddr() net.Addr
// RemoteAddr returns the destination network address.
RemoteAddr() net.Addr
// confirms to protect.Conn
Write([]byte) (int, error)
Read([]byte) (int, error)
// confirms to net.PacketConn
WriteTo([]byte, net.Addr) (int, error)
ReadFrom([]byte) (int, net.Addr, error)
// Implements MinConn, net.Conn, and net.PacketConn
SetDeadline(time.Time) error
SetReadDeadline(time.Time) error
SetWriteDeadline(time.Time) error
}
UDPConn abstracts a UDP connection coming from TUN. This connection should be handled by a registered UDP proxy handler.
type V ¶
type V[T any, K comparable] struct { Val T Err error N atomic.Uint32 // contains filtered or unexported fields }
V is an in-flight or completed Barrier.Do V
type Volatile ¶
Volatile is a non-panicking, non-atomic atomic.Value.
func NewVolatile ¶
NewVolatile returns a new Volatile with the value t. Panics if t is nil.
func NewZeroVolatile ¶
NewVolatile returns a new uninitialized Volatile.
func (*Volatile[T]) Cas ¶
Cas compares and swaps the value of a with new, returns true if the value was swapped. If new is nil, returns true; and sets a to NewZeroVolatile[T] non-atomically. If a is nil or old & new are not of same concrete type, returns false.
func (*Volatile[T]) Load ¶
func (a *Volatile[T]) Load() (t T)
Load returns the value of a. May return zero value. This func is atomic.
func (*Volatile[T]) Store ¶
func (a *Volatile[T]) Store(t T)
Store stores the value t; creates a new Volatile[T] if t is nil. If a is nil, does nothing. This func is not atomic.
func (*Volatile[T]) Swap ¶
func (a *Volatile[T]) Swap(new T) (old T)
Swap assigns new and returns the old value, atomically. If a is nil, it returns zero value. If new is nil, returns old value; and sets a to NewZeroVolatile[T]. If old & new are not of the same concrete type, it panics.
func (*Volatile[T]) Tango ¶
func (a *Volatile[T]) Tango(new T) (old T)
Tango retrieves old value and loads in new non-atomically. If a is nil, returns zero value. If new is nil, returns zero value; and sets a to NewZeroVolatile[T]. old & new need not be the same concrete type. This func is not atomic.
type WeakRef ¶
type WeakRef[V any] struct { // contains filtered or unexported fields }