ipc

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BATCH_NOTIFY = 32      // 批量通知大小
	BUFFER_SIZE  = 1 << 10 // 1kb/缓冲区
	BUF_COUNT    = 1024    // 环形缓冲区数量
	CACHE_LINE   = 64      // 缓存行大小
	Timeout      = 500     // 毫秒
	MEM_SIZE     = int(unsafe.Sizeof(ShmHeader{})) + BUF_COUNT*int(unsafe.Sizeof(ShmBuffer{}))
)
View Source
const (
	PROT_READ     = 0x1
	PROT_WRITE    = 0x2
	MAP_SHARED    = 0x1
	MAP_LOCKED    = 0x2000
	MADV_HUGEPAGE = 0xe
)

Variables

This section is empty.

Functions

func Ftruncate

func Ftruncate(fd int, size int64) error

设置内存大小

func Madvise

func Madvise(b []byte, advice int) error

内存预分配

func Mmap

func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)

映射内存片

func Munmap

func Munmap(addr []byte) error

取消映射

func SchedYield

func SchedYield() error

让出执行权

func Shm_Open

func Shm_Open(name string, flag int, perm os.FileMode) (int, error)

打开共享内存

func Shm_Unlink(name string) error

取消内存共享

Types

type ShmBuffer

type ShmBuffer struct {
	ReqId  uint64            `json:"req_id"`
	Length uint32            `json:"length"`
	Data   [BUFFER_SIZE]byte `json:"data"`
}

type ShmHeader

type ShmHeader struct {
	WriteIdx uint64 `json:"write_idx"`

	ReadIdx uint64 `json:"read_idx"`

	Futex [32]byte `json:"futex"`
	// contains filtered or unexported fields
}

请求内存结构

func GetShmPointers

func GetShmPointers(addr uintptr) (*ShmHeader, *[BUF_COUNT]ShmBuffer)

Jump to

Keyboard shortcuts

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