mirror of
https://gitee.com/zhangsken/aliyunpan.git
synced 2026-10-16 02:23:49 +08:00
add download action for sync
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
package collection
|
||||
|
||||
import "sync"
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
type QueueItem interface {
|
||||
HashCode() string
|
||||
}
|
||||
|
||||
type Queue struct {
|
||||
queueList []interface{}
|
||||
@@ -21,6 +27,21 @@ func (q *Queue) Push(item interface{}) {
|
||||
q.queueList = append(q.queueList, item)
|
||||
}
|
||||
|
||||
func (q *Queue) PushUnique(item interface{}) {
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
if q.queueList == nil {
|
||||
q.queueList = []interface{}{}
|
||||
} else {
|
||||
for _, qItem := range q.queueList {
|
||||
if item.(QueueItem).HashCode() == qItem.(QueueItem).HashCode() {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
q.queueList = append(q.queueList, item)
|
||||
}
|
||||
|
||||
func (q *Queue) Pop() interface{} {
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user