github.com/MetalBlockchain/metalgo@v1.11.9/snow/engine/common/halter.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package common 5 6 import ( 7 "context" 8 "sync/atomic" 9 ) 10 11 var _ Haltable = (*Halter)(nil) 12 13 type Haltable interface { 14 Halt(context.Context) 15 Halted() bool 16 } 17 18 type Halter struct { 19 halted uint32 20 } 21 22 func (h *Halter) Halt(context.Context) { 23 atomic.StoreUint32(&h.halted, 1) 24 } 25 26 func (h *Halter) Halted() bool { 27 return atomic.LoadUint32(&h.halted) == 1 28 }