Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomicDoN ¶ added in v0.3.0
func AtomicDoN(actors []*Actor, f func())
AtomicDoN runs f with the locks of ALL given actors held together, acquired in a canonical (pointer-address) order and released in reverse. This is the deadlock-free way to operate on several instances atomically — use it instead of nesting AtomicDo on different instances (which does NOT lock the inner one).
It is a general-purpose primitive: any struct that holds an *Actor (via NewActor) gets per-instance serialization (AtomicDo) AND deadlock-free multi-instance locking (AtomicDoN). Actors may belong to different groups; nil or already-held actors are skipped and duplicate pointers de-duplicated.
// Lock two custom structs together, deadlock-free:
atomic.AtomicDoN([]*atomic.Actor{a.actor, b.actor}, func() {
b.data = append(b.data, a.data...)
})
func AtomicDoNWithInit ¶ added in v0.3.0
func AtomicDoNWithInit(actors []*Actor, initHooks []func(), f func())
AtomicDoNWithInit is AtomicDoN plus a per-actor one-time init hook (initHooks[i] pairs with actors[i]); nil entries and short slices are fine.
func AtomicDoWithInit ¶
AtomicDoWithInit executes f with actor-style serialization and runs initHook once.
Types ¶
type Actor ¶
type Actor = core.AtomicActor
Actor provides actor-style serialized execution for any struct.