fbuffer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OsPageSize = os.Getpagesize()
)

Functions

func NewFixedBuffer

func NewFixedBuffer(f file, bufSize int) (*fixedbuffer, error)

Types

type ZeroMmap

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

concurrent operations are unsafe

func NewZeroMmap

func NewZeroMmap(f *os.File, mmSize int, mapPort, mapFlag int, lock bool) (*ZeroMmap, error)

func (*ZeroMmap) Close

func (zm *ZeroMmap) Close() error

Close 释放分配器

func (*ZeroMmap) NextAt

func (zm *ZeroMmap) NextAt(offset int64, n int) ([]byte, error)

NextAt 从offset处获取n个字节,如果参数合法,则获取到bytes长度一定为n, offset可以比当前文件的size大,获取的bytes用于写入数据

func (*ZeroMmap) ReadAt

func (zm *ZeroMmap) ReadAt(offset int64, n int) ([]byte, error)

ReadAt 从offset处读取n个字节,除非读到文件末尾,否则读取到的长度一定为n, 其主要用来读取文件的内容

func (*ZeroMmap) Size

func (zm *ZeroMmap) Size() int64

func (*ZeroMmap) Sync

func (zm *ZeroMmap) Sync() error

Sync 将映射区的数据刷新到磁盘

func (*ZeroMmap) Truncate

func (zm *ZeroMmap) Truncate(size int64) error

Truncate 同步文件的大小,一般对文件进行Truncate的时候,同步调用buffer.Truncate,fSize防止从映射区中读取的数据超出文件大小

func (*ZeroMmap) WriteBack

func (zm *ZeroMmap) WriteBack() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL