shm

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2016 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Overview

Package shm implements shared memory objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DestroyMemoryObject

func DestroyMemoryObject(name string) error

DestroyMemoryObject permanently removes given memory object.

Types

type MemoryObject

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

MemoryObject represents an object which can be used to map shared memory regions into the process' address space.

func NewMemoryObject

func NewMemoryObject(name string, flag int, perm os.FileMode) (*MemoryObject, error)

NewMemoryObject creates a new shared memory object.

name - a name of the object. should not contain '/' and exceed 255 symbols (30 on darwin).
size - object size.
flag - flag is a combination of open flags from 'os' package.
perm - object's permission bits.

func (*MemoryObject) Close

func (obj *MemoryObject) Close() error

Close closes object's underlying file object. Darwin: a call to Close() causes invalid argument error, if the object was not truncated. So, in this case we return nil as an error.

func (*MemoryObject) Destroy

func (obj *MemoryObject) Destroy() error

Destroy closes the object and removes it permanently.

func (*MemoryObject) Fd

func (obj *MemoryObject) Fd() uintptr

Fd returns a descriptor of the object's underlying file object.

func (*MemoryObject) Name

func (obj *MemoryObject) Name() string

Name returns the name of the object as it was given to NewMemoryObject().

func (*MemoryObject) Size

func (obj *MemoryObject) Size() int64

Size returns the current object size. Darwin: it may differ from the size passed passed to Truncate.

func (*MemoryObject) Truncate

func (obj *MemoryObject) Truncate(size int64) error

Truncate resizes the shared memory object. Darwin: it is possible to truncate an object only once after it was created. Darwin: the size should be divisible by system page size, otherwise the size is set to the nearest page size divider greater, then the given size.

type SharedMemoryObject

type SharedMemoryObject interface {
	Size() int64
	Truncate(size int64) error
	Close() error
	Destroy() error
	mmf.Mappable
}

SharedMemoryObject is an interface, which must be implemented by any implemetation of an object used for mapping into memory.

func NewMemoryObjectSize added in v0.2.0

func NewMemoryObjectSize(name string, flag int, perm os.FileMode, size int64) (SharedMemoryObject, bool, error)

NewMemoryObjectSize opens or creates a shared memory object with the given name. If the object was created, it is truncated to 'size'. Otherwise, checks, that the existing object is at least 'size' bytes long. Returns an object, true, if it was created, and an error.

Directories

Path Synopsis
internal
test command

Jump to

Keyboard shortcuts

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