From: Matt Joiner Date: Sun, 31 Jan 2016 07:35:23 +0000 (+1100) Subject: util/levelmu is no longer in use X-Git-Tag: v1.0.0~935 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=f98d9c0a47316bb9aedbc6eb97b9d98a6c86a350;p=btrtrc.git util/levelmu is no longer in use --- diff --git a/util/levelmu/levelmu.go b/util/levelmu/levelmu.go deleted file mode 100644 index 5970d721..00000000 --- a/util/levelmu/levelmu.go +++ /dev/null @@ -1,39 +0,0 @@ -package levelmu - -import ( - "sync" -) - -type LevelMutex struct { - mus []sync.Mutex - // Protected by the very last mutex. - lastLevel int -} - -func (lm *LevelMutex) Init(levels int) { - if lm.mus != nil { - panic("level mutex already initialized") - } - lm.mus = make([]sync.Mutex, levels) -} - -func (lm *LevelMutex) Lock() { - lm.LevelLock(0) -} - -func (lm *LevelMutex) Unlock() { - stopLevel := lm.lastLevel - for i := len(lm.mus) - 1; i >= stopLevel; i-- { - lm.mus[i].Unlock() - } -} - -func (lm *LevelMutex) LevelLock(level int) { - if level >= len(lm.mus) { - panic("lock level exceeds configured level count") - } - for l := level; l < len(lm.mus); l++ { - lm.mus[l].Lock() - } - lm.lastLevel = level -}