Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 9 of 9 for SetBlocking (0.17 sec)

  1. 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 Jun 16 00:44:34 UTC 2024
    - Last Modified: Wed May 15 00:11:04 UTC 2024
    - 1.7K bytes
    - Viewed (0)
  2. 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 Jun 16 00:44:34 UTC 2024
    - Last Modified: Wed May 15 00:11:04 UTC 2024
    - 2.1K bytes
    - Viewed (0)
  3. src/runtime/debug/stack.go

    		// crash monitor is a child process, it may inherit
    		// it, so it will never see EOF from the pipe even
    		// when this process crashes.
    		//
    		// A side effect of Fd() is that it calls SetBlocking,
    		// which is important so that writes of a crash report
    		// to a full pipe buffer don't get lost.
    		fd2, _, err := poll.DupCloseOnExec(int(f.Fd()))
    		if err != nil {
    			return err
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 16 15:19:04 UTC 2024
    - 3.2K bytes
    - Viewed (0)
  4. src/internal/poll/fd_unix.go

    	if fd.isBlocking == 0 {
    		runtime_Semacquire(&fd.csema)
    	}
    
    	return err
    }
    
    // SetBlocking puts the file into blocking mode.
    func (fd *FD) SetBlocking() error {
    	if err := fd.incref(); err != nil {
    		return err
    	}
    	defer fd.decref()
    	// Atomic store so that concurrent calls to SetBlocking
    	// do not cause a race condition. isBlocking only ever goes
    	// from 0 to 1 so there is no real race here.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri May 31 04:09:44 UTC 2024
    - 17.9K bytes
    - Viewed (0)
  5. 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 Jun 16 00:44:34 UTC 2024
    - Last Modified: Wed May 15 00:11:04 UTC 2024
    - 26.8K bytes
    - Viewed (0)
  6. 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 Jun 16 00:44:34 UTC 2024
    - Last Modified: Wed May 15 00:11:04 UTC 2024
    - 6.1K bytes
    - Viewed (0)
  7. 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 Jun 16 00:44:34 UTC 2024
    - Last Modified: Wed May 15 00:11:04 UTC 2024
    - 13.3K bytes
    - Viewed (0)
  8. src/os/file_unix.go

    	// because historically we have always returned a descriptor
    	// opened in blocking mode. The File will continue to work,
    	// but any blocking operation will tie up a thread.
    	if f.nonblock {
    		f.pfd.SetBlocking()
    	}
    
    	return uintptr(f.pfd.Sysfd)
    }
    
    // NewFile returns a new File with the given file descriptor and
    // name. The returned value will be nil if fd is not a valid file
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 29 13:52:34 UTC 2024
    - 14.9K bytes
    - Viewed (0)
  9. src/cmd/trace/testdata/go122.test

    String id=142
    	data="internal/poll.(*FD).Close"
    String id=143
    	data="net.(*netFD).Close"
    String id=144
    	data="net.(*conn).Close"
    String id=145
    	data="internal/poll.(*FD).SetBlocking"
    String id=146
    	data="os.(*File).Fd"
    String id=147
    	data="sync.(*WaitGroup).Add"
    String id=148
    	data="/usr/local/google/home/mknyszek/work/go-1/src/sync/waitgroup.go"
    String id=149
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri May 17 17:15:58 UTC 2024
    - 166K bytes
    - Viewed (0)
Back to top