Add a Sub method to atomics (#5)

* Add a Sub method to atomics

Fixes #3.

* Invert integer sign without multiplying
This commit is contained in:
Akshay Shah
2016-05-28 22:54:33 -07:00
parent be53a1df0f
commit 2051a605b9
3 changed files with 36 additions and 8 deletions

View File

@@ -36,6 +36,7 @@ func TestStressInt32(t *testing.T) {
for j := 0; j < _iterations; j++ {
atom.Load()
atom.Add(1)
atom.Sub(2)
atom.Inc()
atom.Dec()
atom.CAS(1, 0)
@@ -54,6 +55,7 @@ func TestStressInt64(t *testing.T) {
for j := 0; j < _iterations; j++ {
atom.Load()
atom.Add(1)
atom.Sub(2)
atom.Inc()
atom.Dec()
atom.CAS(1, 0)
@@ -72,6 +74,7 @@ func TestStressUint32(t *testing.T) {
for j := 0; j < _iterations; j++ {
atom.Load()
atom.Add(1)
atom.Sub(2)
atom.Inc()
atom.Dec()
atom.CAS(1, 0)
@@ -90,6 +93,7 @@ func TestStressUint64(t *testing.T) {
for j := 0; j < _iterations; j++ {
atom.Load()
atom.Add(1)
atom.Sub(2)
atom.Inc()
atom.Dec()
atom.CAS(1, 0)