()
| 78 | } |
| 79 | |
| 80 | func (this *RWQueue) GetOne() interface{} { |
| 81 | this.read_lock.Lock() |
| 82 | defer this.read_lock.Unlock() |
| 83 | |
| 84 | if this.read_queue.empty() == true { |
| 85 | this.write_lock.Lock() |
| 86 | if this.exchange() == false { |
| 87 | this.write_lock.Unlock() |
| 88 | return 0 |
| 89 | } |
| 90 | this.write_lock.Unlock() |
| 91 | } |
| 92 | |
| 93 | read_queue := this.read_queue |
| 94 | val, ret := read_queue.pop() |
| 95 | if ret == false { |
| 96 | return nil |
| 97 | } |
| 98 | return val |
| 99 | } |
| 100 | |
| 101 | func (this *RWQueue) Empty() bool { |
| 102 | this.read_lock.Lock() |