Movatterモバイル変換


[0]ホーム

URL:


buffer

package
v1.77.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2025 License:Apache-2.0Imports:6Imported by:0

Details

Repository

github.com/grpc/grpc-go

Links

Documentation

Overview

Package buffer provides a high-performant lock free implementation of acircular buffer used by the profiling code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeCircularBuffer

type CircularBuffer struct {// contains filtered or unexported fields}

CircularBuffer is a lock-free data structure that supports Push and Drainoperations.

Note that CircularBuffer is built for performance more than reliability.That is, some Push operations may fail without retries in some situations(such as during a Drain operation). Order of pushes is not maintainedeither; that is, if A was pushed before B, the Drain operation may return anarray with B before A. These restrictions are acceptable within gRPC'sprofiling, but if your use-case does not permit these relaxed constraintsor if performance is not a primary concern, you should probably use alock-based data structure such as internal/buffer.UnboundedBuffer.

funcNewCircularBuffer

func NewCircularBuffer(sizeuint32) (*CircularBuffer,error)

NewCircularBuffer allocates a circular buffer of size size and returns areference to the struct. Only circular buffers of size 2^k are allowed(saves us from having to do expensive modulo operations).

func (*CircularBuffer)Drain

func (cb *CircularBuffer) Drain() []any

Drain allocates and returns an array of things Pushed in to the circularbuffer. Push order is not maintained; that is, if B was Pushed after A,drain may return B at a lower index than A in the returned array.

func (*CircularBuffer)Push

func (cb *CircularBuffer) Push(xany)

Push pushes an element in to the circular buffer. Guaranteed to complete ina finite number of steps (also lock-free). Does not guarantee that pushorder will be retained. Does not guarantee that the operation will succeedif a Drain operation concurrently begins execution.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp