summaryrefslogtreecommitdiff
path: root/vendor/github.com/docker/go-plugins-helpers/sdk/pool.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-12-01 22:32:08 +0100
committerGitHub <noreply@github.com>2020-12-01 22:32:08 +0100
commit7f084a8ae212f1c2c67e9cfb1f9e4c5470e01870 (patch)
tree7078a75662049ee596cbfecb96c41ad95cee3aa9 /vendor/github.com/docker/go-plugins-helpers/sdk/pool.go
parentc71ad9a557ee80eccde2608939c81906379fa7ae (diff)
parent594ac4a14658a90ad7bc5541dab6349a0c629a5c (diff)
downloadpodman-7f084a8ae212f1c2c67e9cfb1f9e4c5470e01870.tar.gz
podman-7f084a8ae212f1c2c67e9cfb1f9e4c5470e01870.tar.bz2
podman-7f084a8ae212f1c2c67e9cfb1f9e4c5470e01870.zip
Merge pull request #8357 from mheon/add_volume_interface_package
Add API for communicating with Docker volume plugins
Diffstat (limited to 'vendor/github.com/docker/go-plugins-helpers/sdk/pool.go')
-rw-r--r--vendor/github.com/docker/go-plugins-helpers/sdk/pool.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/vendor/github.com/docker/go-plugins-helpers/sdk/pool.go b/vendor/github.com/docker/go-plugins-helpers/sdk/pool.go
new file mode 100644
index 000000000..316775973
--- /dev/null
+++ b/vendor/github.com/docker/go-plugins-helpers/sdk/pool.go
@@ -0,0 +1,18 @@
+package sdk
+
+import (
+ "io"
+ "sync"
+)
+
+const buffer32K = 32 * 1024
+
+var buffer32KPool = &sync.Pool{New: func() interface{} { return make([]byte, buffer32K) }}
+
+// copyBuf uses a shared buffer pool with io.CopyBuffer
+func copyBuf(w io.Writer, r io.Reader) (int64, error) {
+ buf := buffer32KPool.Get().([]byte)
+ written, err := io.CopyBuffer(w, r, buf)
+ buffer32KPool.Put(buf)
+ return written, err
+}