Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Q ¶
type Q struct {
// contains filtered or unexported fields
}
Q is a queue. Uses Go Channel and sync.WaitGroup under the hood.
func New ¶
New returns a new queue with the given max size. No more than max size items can be added to the queue. It uses Golang's channel under the hood. Think this function as make(chan int, maxSize). So, if you set the max size to 0, it will not work as a queue or buffer.
func (*Q) Add ¶
Add adds an item to the queue. It uses wg.Add(n) to keep track of the number of items in the queue.
func (*Q) Done ¶
func (q *Q) Done()
Done removes an item from the queue. It uses wg.Done() to keep track of the number of items in the queue.
func (*Q) Exit ¶
func (q *Q) Exit()
Exit calls q.Done() first then calls runtime.Goexit(). If called inside a goroutine, the goroutine will exit immediately. See https://golang.org/pkg/runtime/#Goexit for the documentation.