File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 1010 ErrStopped = errors .New ("stopped" )
1111)
1212
13- // List is a non-blocking unbounded lock-free channel-based list for Golang .
13+ // List is a non-blocking unbounded lock-free channel-based list.
1414type List [E any , Q ListType [E ]] struct {
1515 out <- chan E
1616 in atomic.Pointer [chan <- E ]
@@ -64,6 +64,8 @@ func (q *List[E, Q]) PutCheck(e E) error {
6464 return ErrStopped
6565}
6666
67+ // Size returns the number of items in the list.
68+ // If the list is closed, returns -1.
6769func (q * List [E , Q ]) Size () int {
6870 select {
6971 case info , ok := <- q .info :
@@ -74,6 +76,7 @@ func (q *List[E, Q]) Size() int {
7476 }
7577}
7678
79+ // Stopped returns whether Stop was called.
7780func (q * List [E , Q ]) Stopped () bool {
7881 return q .in .Load () == nil
7982}
You can’t perform that action at this time.
0 commit comments