github.com/leanovate/gopter@v0.2.9/flag.go (about)

     1  package gopter
     2  
     3  import "sync/atomic"
     4  
     5  // Flag is a convenient helper for an atomic boolean
     6  type Flag struct {
     7  	flag int32
     8  }
     9  
    10  // Get the value of the flag
    11  func (f *Flag) Get() bool {
    12  	return atomic.LoadInt32(&f.flag) > 0
    13  }
    14  
    15  // Set the the flag
    16  func (f *Flag) Set() {
    17  	atomic.StoreInt32(&f.flag, 1)
    18  }
    19  
    20  // Unset the flag
    21  func (f *Flag) Unset() {
    22  	atomic.StoreInt32(&f.flag, 0)
    23  }