- Sort Score
- Result 10 results
- Languages All
Results 1 - 5 of 5 for SetBlocking (0.09 sec)
-
internal/ringbuffer/ring_buffer_benchmark_test.go
b.ResetTimer() for i := 0; i < b.N; i++ { rb.Write(data) } } func BenchmarkRingBuffer_AsyncReadBlocking(b *testing.B) { const sz = 512 const buffers = 10 rb := New(sz * buffers) rb.SetBlocking(true) data := []byte(strings.Repeat("a", sz)) buf := make([]byte, sz) go func() { for { rb.Read(buf) } }() b.ResetTimer() for i := 0; i < b.N; i++ { rb.Write(data) } }
Registered: Sun Nov 03 19:28:11 UTC 2024 - Last Modified: Wed May 15 00:11:04 UTC 2024 - 1.7K bytes - Viewed (0) -
internal/ringbuffer/README.md
meaning that reads and writes will return immediately with an error if the operation cannot be completed. If you want to block when reading or writing, you must enable it: ```go rb := ringbuffer.New(1024).SetBlocking(true) ``` Enabling blocking will cause the ring buffer to behave like a buffered [io.Pipe](https://pkg.go.dev/io#Pipe). Regular Reads will block until data is available, but not wait for a full buffer.
Registered: Sun Nov 03 19:28:11 UTC 2024 - Last Modified: Wed May 15 00:11:04 UTC 2024 - 2.1K bytes - Viewed (0) -
internal/ringbuffer/ring_buffer_test.go
t.Fatalf("expect 16 abcd and 4 1234 but got %s. r.w=%d, r.r=%d", rb.Bytes(nil), rb.w, rb.r) } } func TestRingBuffer_WriteBlocking(t *testing.T) { rb := New(64).SetBlocking(true) // check empty or full if !rb.IsEmpty() { t.Fatalf("expect IsEmpty is true but got false") } if rb.IsFull() { t.Fatalf("expect IsFull is false but got true") } if rb.Length() != 0 {
Registered: Sun Nov 03 19:28:11 UTC 2024 - Last Modified: Wed May 15 00:11:04 UTC 2024 - 26.8K bytes - Viewed (0) -
internal/ringbuffer/ring_buffer.go
size: size, } } // NewBuffer returns a new RingBuffer whose buffer is provided. func NewBuffer(b []byte) *RingBuffer { return &RingBuffer{ buf: b, size: len(b), } } // SetBlocking sets the blocking mode of the ring buffer. // If block is true, Read and Write will block when there is no data to read or no space to write. // If block is false, Read and Write will return ErrIsEmpty or ErrIsFull immediately.
Registered: Sun Nov 03 19:28:11 UTC 2024 - Last Modified: Wed May 15 00:11:04 UTC 2024 - 13.3K bytes - Viewed (0) -
cmd/bitrot-streaming.go
h := algo.New() buf := globalBytePoolCap.Load().Get() rb := ringbuffer.NewBuffer(buf[:cap(buf)]).SetBlocking(true) bw := &streamingBitrotWriter{ iow: ioutil.NewDeadlineWriter(rb.WriteCloser(), globalDriveConfig.GetMaxTimeout()), closeWithErr: rb.CloseWithError, h: h, shardSize: shardSize,
Registered: Sun Nov 03 19:28:11 UTC 2024 - Last Modified: Wed Aug 21 12:20:54 UTC 2024 - 6K bytes - Viewed (0)