Struct: s3manager.BufferedReadSeekerWriteToPool

import "../ibm-cos-sdk-go/service/s3/s3manager"

Overview

BufferedReadSeekerWriteToPool uses a sync.Pool to create and reuse []byte slices for buffering parts in memory

Implemented Interfaces

s3crypto.Cipher, s3manager.ReadSeekerWriteTo, s3manager.ReadSeekerWriteToProvider, s3manager.WriterReadFrom

Constructor Functions collapse

Method Summary collapse

Function Details

func NewBufferedReadSeekerWriteToPool(size int) *BufferedReadSeekerWriteToPool

NewBufferedReadSeekerWriteToPool will return a new BufferedReadSeekerWriteToPool that will create a pool of reusable buffers . If size is less then < 64 KiB then the buffer will default to 64 KiB. Reason: io.Copy from writers or readers that don't support io.WriteTo or io.ReadFrom respectively will default to copying 32 KiB.



40
41
42
43
44
45
46
47
48
49
50
// File 'service/s3/s3manager/read_seeker_write_to.go', line 40

func NewBufferedReadSeekerWriteToPool(size int) *BufferedReadSeekerWriteToPool { if size < 65536 { size = 65536 } return &BufferedReadSeekerWriteToPool{ pool: sync.Pool{New: func() interface{} { return make([]byte, size) }}, } }

Method Details

func (p *BufferedReadSeekerWriteToPool) GetWriteTo(seeker io.ReadSeeker) (r ReadSeekerWriteTo, cleanup func())

GetWriteTo will wrap the provided io.ReadSeeker with a BufferedReadSeekerWriteTo. The provided cleanup must be called after operations have been completed on the returned io.ReadSeekerWriteTo in order to signal the return of resources to the pool.



55
56
57
58
59
60
61
62
63
64
// File 'service/s3/s3manager/read_seeker_write_to.go', line 55

func (p *BufferedReadSeekerWriteToPool) GetWriteTo(seeker io.ReadSeeker) (r ReadSeekerWriteTo, cleanup func()) { buffer := p.pool.Get().([]byte) r = &BufferedReadSeekerWriteTo{BufferedReadSeeker: NewBufferedReadSeeker(seeker, buffer)} cleanup = func() { p.pool.Put(buffer) } return r, cleanup }