Skip to content

Instantly share code, notes, and snippets.

@shixzie
Created July 29, 2017 04:08
Show Gist options
  • Select an option

  • Save shixzie/37b78ec57f0d9dabeecc1dc3747466f7 to your computer and use it in GitHub Desktop.

Select an option

Save shixzie/37b78ec57f0d9dabeecc1dc3747466f7 to your computer and use it in GitHub Desktop.

Revisions

  1. shixzie created this gist Jul 29, 2017.
    9 changes: 9 additions & 0 deletions sync_atomic_1.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    // Why not
    func Add<T>(addr *T, delta T) (new T)

    otherInt32 := atomic.Add<int32>(&myInt32, 32)

    // Instead of
    func AddInt32(addr *int32, delta int32) (new int32)

    otherInt32 := atomic.AddInt32(&myInt32, 32)