github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/state/marker.go (about)

     1  package state
     2  
     3  import (
     4  	"sync/atomic"
     5  )
     6  
     7  // Marker is a utility type used to track if a condition has occurred. It is
     8  // safe for concurrent usage and designed for usage on hot paths. The zero value
     9  // of Marker is unmarked.
    10  type Marker struct {
    11  	// storage is the underlying marker storage.
    12  	storage atomic.Bool
    13  }
    14  
    15  // Mark idempotently marks the marker.
    16  func (m *Marker) Mark() {
    17  	m.storage.Store(true)
    18  }
    19  
    20  // Marked returns whether or not the marker is marked.
    21  func (m *Marker) Marked() bool {
    22  	return m.storage.Load()
    23  }