Rename package circ to queue.
This commit is contained in:
14
mq/lib.go
14
mq/lib.go
@@ -31,7 +31,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"gogs.humancabbage.net/sam/priorityq"
|
||||
"gogs.humancabbage.net/sam/priorityq/circ"
|
||||
"gogs.humancabbage.net/sam/priorityq/queue"
|
||||
)
|
||||
|
||||
// Q is a concurrent, dual-priority message queue.
|
||||
@@ -41,8 +41,8 @@ type Q[T any] struct {
|
||||
|
||||
// Make a new queue.
|
||||
func Make[T any](cap int) Q[T] {
|
||||
high := circ.Make[T](cap)
|
||||
low := circ.Make[T](cap)
|
||||
high := queue.Make[T](cap)
|
||||
low := queue.Make[T](cap)
|
||||
s := &state[T]{
|
||||
high: high,
|
||||
low: low,
|
||||
@@ -55,8 +55,8 @@ func Make[T any](cap int) Q[T] {
|
||||
|
||||
type state[T any] struct {
|
||||
mu sync.Mutex
|
||||
high circ.B[T]
|
||||
low circ.B[T]
|
||||
high queue.Q[T]
|
||||
low queue.Q[T]
|
||||
canSendHigh sync.Cond
|
||||
canSendLow sync.Cond
|
||||
canRecv sync.Cond
|
||||
@@ -163,7 +163,7 @@ func (s *state[T]) TrySendLow(value T) error {
|
||||
return s.trySend(value, &s.low)
|
||||
}
|
||||
|
||||
func (s *state[T]) send(value T, buf *circ.B[T], cond *sync.Cond) {
|
||||
func (s *state[T]) send(value T, buf *queue.Q[T], cond *sync.Cond) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
for {
|
||||
@@ -181,7 +181,7 @@ func (s *state[T]) send(value T, buf *circ.B[T], cond *sync.Cond) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *state[T]) trySend(value T, buf *circ.B[T]) error {
|
||||
func (s *state[T]) trySend(value T, buf *queue.Q[T]) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.closed {
|
||||
|
Reference in New Issue
Block a user