Collection of dirty hacks in Go.
- Repeat
sync.Onceonce more. - Check if
sync.Mutex/sync.RWMutexis locked. []byte <-> stringconversion without additional allocation.
Cause what you see, you might not get
And we can bet, so don't you get souped yet
Scheming on a thing, that's a mirage
I'm trying to tell you now, it's sabotage
Whhhhhyyyyyy??????
(c) Beastie Boys - Sabotage
- You can repeat
sync.Onceas much as you want:
var once sync.Once
once.Do(myFunc)
sabotage.ResetSyncOnce(&once) or check if it was invoked earlier:
if sabotage.IsOnceDone(&once) {
println("well-well-well")
}- You can unlock any mutex from anywhere:
var mu sync.Mutex
// let's yolo begins
sabotage.UnlockMutex(&mu)or check if it's locked:
if sabotage.IsMutexLocked(&mu) {
for {
// let's wait a bit
}
}