File: flag.go

package info (click to toggle)
golang-github-leanovate-gopter 0.2.9%2Bgit20210201.bbbf00e-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 696 kB
  • sloc: makefile: 37
file content (23 lines) | stat: -rw-r--r-- 376 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package gopter

import "sync/atomic"

// Flag is a convenient helper for an atomic boolean
type Flag struct {
	flag int32
}

// Get the value of the flag
func (f *Flag) Get() bool {
	return atomic.LoadInt32(&f.flag) > 0
}

// Set the the flag
func (f *Flag) Set() {
	atomic.StoreInt32(&f.flag, 1)
}

// Unset the flag
func (f *Flag) Unset() {
	atomic.StoreInt32(&f.flag, 0)
}