queue add RLockRange method.

This commit is contained in:
boyce
2019-03-26 16:11:39 +08:00
parent 83f38bcf22
commit a854355952
2 changed files with 10 additions and 1 deletions

View File

@@ -43,6 +43,15 @@ func (q *SyncQueue) Pop() interface{} {
return q.que.Pop()
}
func (q *SyncQueue) RLockRange(f func(interface{})) {
q.mutex.RLock()
defer q.mutex.RUnlock()
for i := 0; i < q.que.Length(); i++ {
f(q.Get(i))
}
}
func NewSyncQueue() *SyncQueue {
syncQueue := SyncQueue{}
syncQueue.que = NewQueue()