Created
August 10, 2016 14:50
-
-
Save jasonkeene/d73299585966c80057404271c5216fec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type lock struct { | |
| l uint32 | |
| } | |
| func (l *lock) Lock() { | |
| for { | |
| if atomic.CompareAndSwapUint32(&l.l, 0, 1) { | |
| return | |
| } | |
| } | |
| } | |
| func (l *lock) Unlock() { | |
| atomic.StoreUint32(&l.l, 0) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment