File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ func (q *queue[T]) Limit(context.Context) (int, error) {
6464}
6565
6666func (q * queue [T ]) Len (context.Context ) (int , error ) {
67+ q .mu .Lock ()
68+ defer q .mu .Unlock ()
6769 return q .list .Len (), nil
6870}
6971
@@ -74,7 +76,7 @@ func (q *queue[T]) setCap(ctx context.Context, c int) {
7476 q .recordLimit (ctx , c )
7577}
7678
77- func (q * queue [T ]) refresh (ctx context.Context ) {
79+ func (q * queue [T ]) record (ctx context.Context ) {
7880 q .recordUsage (ctx , q .list .Len ())
7981 q .recordLimit (ctx , q .cap )
8082}
@@ -89,7 +91,7 @@ func (q *queue[T]) Put(ctx context.Context, t T) error {
8991 }
9092 q .list .PushBack (t )
9193 q .cond .Signal ()
92- q .refresh (ctx )
94+ q .record (ctx )
9395 return nil
9496}
9597
@@ -103,7 +105,7 @@ func (q *queue[T]) Get(ctx context.Context) (T, error) {
103105 }
104106 t := q .list .Front ()
105107 q .list .Remove (t )
106- q .refresh (ctx )
108+ q .record (ctx )
107109 return t .Value .(T ), nil
108110}
109111
@@ -129,7 +131,7 @@ func (q *queue[T]) Wait(ctx context.Context) (T, error) {
129131 }
130132 t := q .list .Front ()
131133 q .list .Remove (t )
132- q .refresh (ctx )
134+ q .record (ctx )
133135 return t .Value .(T ), nil
134136}
135137
You can’t perform that action at this time.
0 commit comments