Skip to content

Commit

Permalink
adding DequeueOrWaitForNextElementContext to Queue interface
Browse files Browse the repository at this point in the history
  • Loading branch information
enriquebris committed Apr 14, 2020
1 parent c043815 commit decfc52
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions queue.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package goconcurrentqueue

import "context"

// Queue interface with basic && common queue functions
type Queue interface {
// Enqueue element
Expand All @@ -9,6 +11,10 @@ type Queue interface {
// DequeueOrWaitForNextElement dequeues an element (if exist) or waits until the next element gets enqueued and returns it.
// Multiple calls to DequeueOrWaitForNextElement() would enqueue multiple "listeners" for future enqueued elements.
DequeueOrWaitForNextElement() (interface{}, error)
// DequeueOrWaitForNextElementContext dequeues an element (if exist) or waits until the next element gets enqueued and returns it.
// Multiple calls to DequeueOrWaitForNextElementContext() would enqueue multiple "listeners" for future enqueued elements.
// When the passed context expires this function exits and returns the context' error
DequeueOrWaitForNextElementContext(context.Context) (interface{}, error)
// Get number of enqueued elements
GetLen() int
// Get queue's capacity
Expand Down

0 comments on commit decfc52

Please sign in to comment.