1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
package pom
import "sync"
// artifactQueue the queue of Items
type artifactQueue struct {
items []artifact
lock sync.RWMutex
}
func newArtifactQueue() *artifactQueue {
return &artifactQueue{}
}
func (s *artifactQueue) enqueue(items ...artifact) {
s.lock.Lock()
s.items = append(s.items, items...)
s.lock.Unlock()
}
func (s *artifactQueue) dequeue() artifact {
s.lock.Lock()
item := s.items[0]
s.items = s.items[1:]
s.lock.Unlock()
return item
}
// IsEmpty returns true if the queue is empty
func (s *artifactQueue) IsEmpty() bool {
return len(s.items) == 0
}
|