Documentation ¶
Index ¶
Constants ¶
const ( S_IRUSR = 0400 /* Read by owner. */ //nolint:golint,stylecheck S_IWUSR = 0200 /* Write by owner. */ //nolint:golint,stylecheck S_IRGRP = S_IRUSR >> 3 /* Read by group. */ //nolint:golint,stylecheck S_IWGRP = S_IWUSR >> 3 /* Write by group. */ //nolint:golint,stylecheck )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flag ¶
type Flag int
const ( /* resource get request flags */ IPC_CREAT Flag = 00001000 /* create if key is nonexistent */ //nolint:golint,stylecheck IPC_EXCL Flag = 00002000 /* fail if key exists */ //nolint:golint,stylecheck IPC_NOWAIT Flag = 00004000 /* return error on wait */ //nolint:golint,stylecheck /* Permission flag for shmget. */ SHM_R Flag = 0400 /* or S_IRUGO from <linux/stat.h> */ //nolint:golint,stylecheck SHM_W Flag = 0200 /* or S_IWUGO from <linux/stat.h> */ //nolint:golint,stylecheck /* Flags for `shmat'. */ SHM_RDONLY Flag = 010000 /* attach read-only else read-write */ //nolint:golint,stylecheck SHM_RND Flag = 020000 /* round attach address to SHMLBA */ //nolint:golint,stylecheck /* Commands for `shmctl'. */ SHM_REMAP Flag = 040000 /* take-over region on attach */ //nolint:golint,stylecheck SHM_EXEC Flag = 0100000 /* execution access */ //nolint:golint,stylecheck SHM_LOCK Flag = 11 /* lock segment (root only) */ //nolint:golint,stylecheck SHM_UNLOCK Flag = 12 /* unlock segment (root only) */ //nolint:golint,stylecheck )
https://github.com/torvalds/linux/blob/master/include/uapi/linux/ipc.h
type SharedMemorySegment ¶
type SharedMemorySegment struct {
// contains filtered or unexported fields
}
func AttachToShmSegment ¶
func AttachToShmSegment(shmID int, size uint, permission int) (*SharedMemorySegment, error)
AttachToShmSegment used to attach to the existing shared memory segment by shared memory ID. Shared memory ID can be known or you find it by typing the following command: ipcs -m --human. If there is no such shm segment by shmId, the error will be shown.
func NewSharedMemorySegment ¶
func NewSharedMemorySegment(key int, size uint, permission int, flags ...Flag) (*SharedMemorySegment, error)
The args are:
key - int, used as uniques identifier for the shared memory segment size - uint, size in bytes to allocate permission - int, if passed zero, 0600 will be used by default flags - IPC_CREAT, IPC_EXCL, IPC_NOWAIT. More info can be found here https://github.com/torvalds/linux/blob/master/include/uapi/linux/ipc.h
func (*SharedMemorySegment) Clear ¶
func (s *SharedMemorySegment) Clear()
Clear by behavior is similar to the std::memset(..., 0, ...)
func (*SharedMemorySegment) Detach ¶
func (s *SharedMemorySegment) Detach() error
Detach used to detach from memory segment
func (*SharedMemorySegment) Read ¶
func (s *SharedMemorySegment) Read(data []byte) error
Read data segment. Attention, the segment to read will be equal to data function arg len
func (*SharedMemorySegment) Write ¶
func (s *SharedMemorySegment) Write(data []byte)
write is not thread safe operation should be protected via semaphore