We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ca10695 commit 4476701Copy full SHA for 4476701
1 file changed
queue/linked_blocking_queue.go
@@ -407,8 +407,15 @@ func NewLinkedBlockingQueue(capacity int) *LinkedBlockingQueue {
407
}
408
409
410
-func FromSlice(s []interface{}) (*LinkedBlockingQueue, error) {
411
- q := NewLinkedBlockingQueue(0)
+/**
+ * @Description: create a LinkedBlockingQueue from a slice. if the give capacity is less than the slice's len, FullError will be return
412
+ * @param s
413
+ * @param capacity
414
+ * @return *LinkedBlockingQueue
415
+ * @return error
416
+ */
417
+func FromSlice(s []interface{}, capacity int) (*LinkedBlockingQueue, error) {
418
+ q := NewLinkedBlockingQueue(capacity)
419
q.fullyLock()
420
defer q.fullyUnlock()
421
var n int64 = 0
0 commit comments