github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/process/background.go (about) 1 package process 2 3 import "sync/atomic" 4 5 type Background struct { 6 i int32 7 } 8 9 func (bg *Background) Get() bool { 10 return atomic.LoadInt32(&bg.i) != 0 11 } 12 13 func (bg *Background) Set(v bool) { 14 if v { 15 atomic.StoreInt32(&bg.i, 1) 16 return 17 } 18 19 atomic.StoreInt32(&bg.i, 0) 20 } 21 22 func (bg *Background) String() string { 23 if bg.Get() { 24 return "yes" 25 } 26 27 return "no" 28 }