// Pop removes an item from the queue. This call may block if the queue is
// empty. If the queue is drained Pop() will not block and return nil.
Pop removes an item from the queue. This call may block if the queue is
empty. If the queue is drained Pop() will not block and return nil.
// Pop removes an item from the queue . This call may block if the queue is // empty . If the queue is drained Pop () will not block and return nil .
func (q *Queue) Pop() interface{} {
	if atomic.LoadInt32(q.locked) == 1 &&
		atomic.LoadUint64(q.write.processing) == atomic.LoadUint64(q.read.processing) {
		return nil 
	}
	ticket := atomic.AddUint64(q.read.next, 1) - 1
	slot := ticket % q.capacity
	spin := q.spin
	for ticket >= atomic.LoadUint64(q.write.processing) {
		spin.Yield()
		if atomic.LoadInt32(q.locked) == 1 &&
			atomic.LoadUint64(q.write.processing) == atomic.LoadUint64(q.read.processing) {
			return nil 
		}
	}
	item := q.items[slot]
	for ticket != atomic.LoadUint64(q.read.processing) {
		spin.Yield()
	}
	atomic.AddUint64(q.read.processing, 1)
	return item
}
func ( q * Queue ) Pop ( ) interface { } { if atomic . LoadInt32 ( q . locked ) == 1 && atomic . LoadUint64 ( q . write . processing ) == atomic . LoadUint64 ( q . read . processing ) { return nil } ticket := atomic . AddUint64 ( q . read . next , 1 ) - 1 slot := ticket % q . capacity spin := q . spin for ticket >= atomic . LoadUint64 ( q . write . processing ) { spin . Yield ( ) if atomic . LoadInt32 ( q . locked ) == 1 && atomic . LoadUint64 ( q . write . processing ) == atomic . LoadUint64 ( q . read . processing ) { return nil } } item := q . items [ slot ] for ticket != atomic . LoadUint64 ( q . read . processing ) { spin . Yield ( ) } atomic . AddUint64 ( q . read . processing , 1 ) return item }
Pop removes an item from the queue.
Pop removes an item from the queue .
// Drained? // ### return, closed and no items ### // Get ticket andd slot // Wait for slot to be written to // Drained? // ### return, closed while spinning ### // Wait for other reads to finish