MCPcopy
hub / github.com/davyxu/cellnet / Pick

Method Pick

pipe.go:28–56  ·  view source on GitHub ↗

如果没有数据,发生阻塞

(retList *[]interface{})

Source from the content-addressed store, hash-verified

26
27// 如果没有数据,发生阻塞
28func (self *Pipe) Pick(retList *[]interface{}) (exit bool) {
29
30 self.listGuard.Lock()
31
32 for len(self.list) == 0 {
33 self.listCond.Wait()
34 }
35
36 self.listGuard.Unlock()
37
38 self.listGuard.Lock()
39
40 // 复制出队列
41
42 for _, data := range self.list {
43
44 if data == nil {
45 exit = true
46 break
47 } else {
48 *retList = append(*retList, data)
49 }
50 }
51
52 self.Reset()
53 self.listGuard.Unlock()
54
55 return
56}
57
58func NewPipe() *Pipe {
59 self := &Pipe{}

Callers 3

StartLoopMethod · 0.80
sendLoopMethod · 0.80
sendLoopMethod · 0.80

Calls 2

ResetMethod · 0.95
WaitMethod · 0.65

Tested by

no test coverage detected