summaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/v5/internal/nbconn/bufferqueue.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-06-19 09:56:15 +0200
committerLibravatar GitHub <noreply@github.com>2023-06-19 09:56:15 +0200
commit70357a770f7e84eed1d3d6a0dfc2ce9f30e5c5be (patch)
tree7462b5e97a94a874b488404e2029fd182e9ae030 /vendor/github.com/jackc/pgx/v5/internal/nbconn/bufferqueue.go
parent[chore]: Bump golang.org/x/net from 0.10.0 to 0.11.0 (#1909) (diff)
downloadgotosocial-70357a770f7e84eed1d3d6a0dfc2ce9f30e5c5be.tar.xz
[chore]: Bump github.com/jackc/pgx/v5 from 5.3.1 to 5.4.1 (#1907)
Bumps [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) from 5.3.1 to 5.4.1. - [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md) - [Commits](https://github.com/jackc/pgx/compare/v5.3.1...v5.4.1) --- updated-dependencies: - dependency-name: github.com/jackc/pgx/v5 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/jackc/pgx/v5/internal/nbconn/bufferqueue.go')
-rw-r--r--vendor/github.com/jackc/pgx/v5/internal/nbconn/bufferqueue.go70
1 files changed, 0 insertions, 70 deletions
diff --git a/vendor/github.com/jackc/pgx/v5/internal/nbconn/bufferqueue.go b/vendor/github.com/jackc/pgx/v5/internal/nbconn/bufferqueue.go
deleted file mode 100644
index 4bf25481c..000000000
--- a/vendor/github.com/jackc/pgx/v5/internal/nbconn/bufferqueue.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package nbconn
-
-import (
- "sync"
-)
-
-const minBufferQueueLen = 8
-
-type bufferQueue struct {
- lock sync.Mutex
- queue []*[]byte
- r, w int
-}
-
-func (bq *bufferQueue) pushBack(buf *[]byte) {
- bq.lock.Lock()
- defer bq.lock.Unlock()
-
- if bq.w >= len(bq.queue) {
- bq.growQueue()
- }
- bq.queue[bq.w] = buf
- bq.w++
-}
-
-func (bq *bufferQueue) pushFront(buf *[]byte) {
- bq.lock.Lock()
- defer bq.lock.Unlock()
-
- if bq.w >= len(bq.queue) {
- bq.growQueue()
- }
- copy(bq.queue[bq.r+1:bq.w+1], bq.queue[bq.r:bq.w])
- bq.queue[bq.r] = buf
- bq.w++
-}
-
-func (bq *bufferQueue) popFront() *[]byte {
- bq.lock.Lock()
- defer bq.lock.Unlock()
-
- if bq.r == bq.w {
- return nil
- }
-
- buf := bq.queue[bq.r]
- bq.queue[bq.r] = nil // Clear reference so it can be garbage collected.
- bq.r++
-
- if bq.r == bq.w {
- bq.r = 0
- bq.w = 0
- if len(bq.queue) > minBufferQueueLen {
- bq.queue = make([]*[]byte, minBufferQueueLen)
- }
- }
-
- return buf
-}
-
-func (bq *bufferQueue) growQueue() {
- desiredLen := (len(bq.queue) + 1) * 3 / 2
- if desiredLen < minBufferQueueLen {
- desiredLen = minBufferQueueLen
- }
-
- newQueue := make([]*[]byte, desiredLen)
- copy(newQueue, bq.queue)
- bq.queue = newQueue
-}