forked from TrueCloudLab/frostfs-node
Add Inner Ring code
This commit is contained in:
parent
dadfd90dcd
commit
b7b5079934
400 changed files with 11420 additions and 8690 deletions
44
pkg/local_object_storage/bucket/fsbucket/queue.go
Normal file
44
pkg/local_object_storage/bucket/fsbucket/queue.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package fsbucket
|
||||
|
||||
import "sync"
|
||||
|
||||
type (
|
||||
queue struct {
|
||||
*sync.RWMutex
|
||||
buf []elem
|
||||
}
|
||||
|
||||
elem struct {
|
||||
depth int
|
||||
prefix string
|
||||
path string
|
||||
}
|
||||
)
|
||||
|
||||
func newQueue(n int) *queue {
|
||||
return &queue{
|
||||
RWMutex: new(sync.RWMutex),
|
||||
buf: make([]elem, 0, n),
|
||||
}
|
||||
}
|
||||
|
||||
func (q *queue) Len() int {
|
||||
return len(q.buf)
|
||||
}
|
||||
|
||||
func (q *queue) Push(s elem) {
|
||||
q.Lock()
|
||||
q.buf = append(q.buf, s)
|
||||
q.Unlock()
|
||||
}
|
||||
|
||||
func (q *queue) Pop() (s elem) {
|
||||
q.Lock()
|
||||
if len(q.buf) > 0 {
|
||||
s = q.buf[0]
|
||||
q.buf = q.buf[1:]
|
||||
}
|
||||
q.Unlock()
|
||||
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue