forked from mirror/abool
fixing readme
This commit is contained in:
parent
42463bd9a0
commit
774dbeaec2
25
README.md
25
README.md
|
@ -29,26 +29,25 @@ type Foo struct {
|
||||||
|
|
||||||
## Benchmark:
|
## Benchmark:
|
||||||
|
|
||||||
- Go 1.6.2
|
- Go 1.11.5
|
||||||
- OS X 10.11.4
|
- OS X 10.14.5
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# Read
|
# Read
|
||||||
BenchmarkMutexRead-4 100000000 21.0 ns/op
|
BenchmarkMutexRead-4 100000000 14.7 ns/op
|
||||||
BenchmarkAtomicValueRead-4 200000000 6.30 ns/op
|
BenchmarkAtomicValueRead-4 2000000000 0.45 ns/op
|
||||||
BenchmarkAtomicBoolRead-4 300000000 4.21 ns/op # <--- This package
|
BenchmarkAtomicBoolRead-4 2000000000 0.35 ns/op # <--- This package
|
||||||
|
|
||||||
# Write
|
# Write
|
||||||
BenchmarkMutexWrite-4 100000000 21.6 ns/op
|
BenchmarkMutexWrite-4 100000000 14.5 ns/op
|
||||||
BenchmarkAtomicValueWrite-4 30000000 43.4 ns/op
|
BenchmarkAtomicValueWrite-4 100000000 10.5 ns/op
|
||||||
BenchmarkAtomicBoolWrite-4 200000000 9.87 ns/op # <--- This package
|
BenchmarkAtomicBoolWrite-4 300000000 5.21 ns/op # <--- This package
|
||||||
|
|
||||||
# CAS
|
# CAS
|
||||||
BenchmarkMutexCAS-4 30000000 44.9 ns/op
|
BenchmarkMutexCAS-4 50000000 31.3 ns/op
|
||||||
BenchmarkAtomicBoolCAS-4 100000000 11.7 ns/op # <--- This package
|
BenchmarkAtomicBoolCAS-4 200000000 7.18 ns/op # <--- This package
|
||||||
|
|
||||||
# Toggle
|
# Toggle
|
||||||
BenchmarkMutexToggle-4 50000000 30.7 ns/op
|
BenchmarkMutexToggle-4 50000000 32.6 ns/op
|
||||||
BenchmarkAtomicBoolToggle-4 300000000 5.27 ns/op # <--- This package
|
BenchmarkAtomicBoolToggle-4 300000000 5.21 ns/op # <--- This package
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
2
bool.go
2
bool.go
|
@ -40,7 +40,7 @@ func (ab *AtomicBool) IsSet() bool {
|
||||||
return atomic.LoadInt32((*int32)(ab)) == 1
|
return atomic.LoadInt32((*int32)(ab)) == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTo sets the Boolean with given Boolean.
|
// SetTo sets the boolean with given Boolean.
|
||||||
func (ab *AtomicBool) SetTo(yes bool) {
|
func (ab *AtomicBool) SetTo(yes bool) {
|
||||||
if yes {
|
if yes {
|
||||||
atomic.StoreInt32((*int32)(ab), 1)
|
atomic.StoreInt32((*int32)(ab), 1)
|
||||||
|
|
Loading…
Reference in New Issue