Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for TryWrite (0.06 sec)

  1. internal/ringbuffer/ring_buffer_test.go

    			err = rb.WriteByte(buf[0])
    			if err != nil {
    				t.Fatalf("write failed: %v", err)
    			}
    			wroteBytes++
    			wrote.Write(buf[:1])
    			debugln("WRITE 3\t", 1, wroteBytes)
    
    			// TryWrite
    			n, err = rb.TryWrite(buf[:writeRng.Intn(len(buf))])
    			if err != nil && err != ErrAcquireLock && err != ErrTooMuchDataToWrite && err != ErrIsFull {
    				t.Fatalf("write failed: %v", err)
    			}
    			wroteBytes += n
    Registered: Sun Nov 03 19:28:11 UTC 2024
    - Last Modified: Wed May 15 00:11:04 UTC 2024
    - 26.8K bytes
    - Viewed (0)
  2. internal/ringbuffer/ring_buffer.go

    	}
    	if r.block && wrote > 0 {
    		r.writeCond.Broadcast()
    	}
    
    	return wrote, r.setErr(err, true)
    }
    
    // TryWrite writes len(p) bytes from p to the underlying buf like Write, but it is not blocking.
    // If it has not succeeded to acquire the lock, it return 0 as n and ErrAcquireLock.
    func (r *RingBuffer) TryWrite(p []byte) (n int, err error) {
    	if len(p) == 0 {
    		return 0, r.setErr(nil, false)
    	}
    	ok := r.mu.TryLock()
    Registered: Sun Nov 03 19:28:11 UTC 2024
    - Last Modified: Wed May 15 00:11:04 UTC 2024
    - 13.3K bytes
    - Viewed (0)
Back to top