1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package pool
import (
"time"
"github.com/lightningnetwork/lnd/buffer"
)
const (
// DefaultReadBufferGCInterval is the default interval that a Read will
// perform a sweep to see which expired buffer.Reads can be released to
// the runtime.
DefaultReadBufferGCInterval = 15 * time.Second
// DefaultReadBufferExpiryInterval is the default, minimum interval that
// must elapse before a Read will release a buffer.Read. The maximum
// time before the buffer can be released is equal to the expiry
// interval plus the gc interval.
DefaultReadBufferExpiryInterval = 30 * time.Second
)
// ReadBuffer is a pool of buffer.Read items, that dynamically allocates and
// reclaims buffers in response to load.
type ReadBuffer struct
// NewReadBuffer returns a freshly instantiated ReadBuffer, using the given
// gcInterval and expieryInterval.
func NewReadBuffer(gcInterval, expiryInterval time.Duration) *ReadBuffer
// Take returns a fresh buffer.Read to the caller.
func () *buffer.Read
// Return returns the buffer.Read to the pool, so that it can be cycled or
// released.
func (buf *buffer.Read)