MCPcopy Create free account
hub / github.com/allegro/bigcache / canInsertAfterTail

Method canInsertAfterTail

queue/bytes_queue.go:246–258  ·  view source on GitHub ↗

canInsertAfterTail returns true if it's possible to insert an entry of size of need after the tail of the queue

(need int)

Source from the content-addressed store, hash-verified

244
245// canInsertAfterTail returns true if it's possible to insert an entry of size of need after the tail of the queue
246func (q *BytesQueue) canInsertAfterTail(need int) bool {
247 if q.full {
248 return false
249 }
250 if q.tail >= q.head {
251 return q.capacity-q.tail >= need
252 }
253 // 1. there is exactly need bytes between head and tail, so we do not need
254 // to reserve extra space for a potential empty entry when realloc this queue
255 // 2. still have unused space between tail and head, then we must reserve
256 // at least headerEntrySize bytes so we can put an empty entry
257 return q.head-q.tail == need || q.head-q.tail >= need+minimumHeaderSize
258}
259
260// canInsertBeforeHead returns true if it's possible to insert an entry of size of need before the head of the queue
261func (q *BytesQueue) canInsertBeforeHead(need int) bool {

Callers 1

PushMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected