// Push adds an item to the queue. This call may block if the queue is full.
// An error is returned when the queue is locked.
Push adds an item to the queue. This call may block if the queue is full.
An error is returned when the queue is locked.
// Push adds an item to the queue . This call may block if the queue is full . // An error is returned when the queue is locked .
func (q *Queue) Push(item interface{}) error {
	if atomic.LoadInt32(q.locked) == 1 {
		return LockedError{"Queue is locked"} 
	}
	ticket := atomic.AddUint64(q.write.next, 1) - 1
	slot := ticket % q.capacity
	spin := q.spin
	for ticket-atomic.LoadUint64(q.read.processing) >= q.capacity {
		spin.Yield()
	}
	q.items[slot] = item
	for ticket != atomic.LoadUint64(q.write.processing) {
		spin.Yield()
	}
	atomic.AddUint64(q.write.processing, 1)
	return nil
}
func ( q * Queue ) Push ( item interface { } ) error { if atomic . LoadInt32 ( q . locked ) == 1 { return LockedError { " " } } ticket := atomic . AddUint64 ( q . write . next , 1 ) - 1 slot := ticket % q . capacity spin := q . spin for ticket - atomic . LoadUint64 ( q . read . processing ) >= q . capacity { spin . Yield ( ) } q . items [ slot ] = item for ticket != atomic . LoadUint64 ( q . write . processing ) { spin . Yield ( ) } atomic . AddUint64 ( q . write . processing , 1 ) return nil }
Push adds an item to the queue.
Push adds an item to the queue .
// ### return, closed ### // Get ticket and slot // Wait for pending reads on slot // Wait for previous writers to finish writing