File: queue.go

package info (click to toggle)
golang-github-aquasecurity-go-dep-parser 0.0~git20220110.4a30ebc-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 19,096 kB
  • sloc: xml: 673; php: 7; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 578 bytes parent folder | download
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
}