MCPcopy Create free account
hub / github.com/LyricTian/queue / dispatcher

Method dispatcher

list_queue.go:57–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57func (q *ListQueue) dispatcher() {
58 for {
59 q.lock.RLock()
60 if atomic.LoadUint32(&q.running) != 1 && q.list.Len() == 0 {
61 q.lock.RUnlock()
62 break
63 }
64 ele := q.list.Front()
65 q.lock.RUnlock()
66
67 if ele == nil {
68 time.Sleep(time.Millisecond * 10)
69 continue
70 }
71
72 worker := <-q.workerPool
73 worker <- ele.Value.(Jober)
74
75 q.lock.Lock()
76 q.list.Remove(ele)
77 q.lock.Unlock()
78 }
79}
80
81// Push put the executable task into the queue
82func (q *ListQueue) Push(job Jober) {

Callers 1

RunMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected