shmcore

package module
v0.0.0-...-1b7f1c2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2020 License: MIT Imports: 4 Imported by: 1

README

shmcore

The share memory core

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanObserve

func CanObserve() bool

CanObserve - tell whether shm can observe or not

func CanResume

func CanResume() bool

CanResume - tell whether shm can resume or not

func DelShmByKey

func DelShmByKey(key uint32) error

DelShmByKey - delete shm by the key

func Exist

func Exist(key uint32) error

Exist - tell whether shm exist nor not by the key

func GetShmBytesByKey

func GetShmBytesByKey(key uint32) (uint64, error)

GetShmBytesByKey - get shm bytes by the key

Types

type BucketHead

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

BucketHead - the bucket head

func (*BucketHead) GetBytes

func (head *BucketHead) GetBytes() uint32

GetBytes - get bucket head bytes field for unit cap

func (*BucketHead) GetCount

func (head *BucketHead) GetCount() uint32

GetCount - get bucket head count field for unit num

type BucketUnit

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

BucketUnit - the bucket unit of array

func (*BucketUnit) GetLen

func (unit *BucketUnit) GetLen() uint32

GetLen - get data length for unit

func (*BucketUnit) GetReadSlice

func (unit *BucketUnit) GetReadSlice() []byte

GetReadSlice - get the slice to read

func (*BucketUnit) GetWriteSlice

func (unit *BucketUnit) GetWriteSlice() []byte

GetWriteSlice - get the slice to write

func (*BucketUnit) SetLen

func (unit *BucketUnit) SetLen(len uint32)

SetLen - set data length for unit

type Segment

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

Segment - the segment of shm

func NewSegment

func NewSegment(key uint32, bytes uint64) (*Segment, error)

NewSegment - new a shm segemnt

func NewSegmentWithOption

func NewSegmentWithOption(key uint32, opt *SegmentOption) (*Segment, error)

NewSegmentWithOption - new a shm segment with option

func (*Segment) Attach

func (seg *Segment) Attach() error

Attach - attch the shm

func (*Segment) Detach

func (seg *Segment) Detach()

Detach - detach from the shm

func (*Segment) GetBucketUnit

func (seg *Segment) GetBucketUnit(hindex uint16, uindex uint32) (*BucketUnit, error)

GetBucketUnit - get the bucket unit by index

func (*Segment) Load

func (seg *Segment) Load(hindex uint16, uindex uint32) ([]byte, error)

Load - load data from a bucket unit

func (*Segment) Observe

func (seg *Segment) Observe(cb1 func(*SegmentHead),
	cb2 func(uint16, *BucketHead), cb3 func(uint16, uint32, *BucketUnit)) error

Observe - observe the segment

func (*Segment) Reset

func (seg *Segment) Reset(cb1 func(*SegmentHead),
	cb2 func(uint16, *BucketHead), cb3 func(uint16, uint32, *BucketUnit)) error

Reset - reset the segment

func (*Segment) Resume

func (seg *Segment) Resume(cb1 func(*SegmentHead),
	cb2 func(uint16, *BucketHead), cb3 func(uint16, uint32, *BucketUnit)) error

Resume - resume the segment

func (*Segment) Save

func (seg *Segment) Save(hindex uint16, uindex uint32, data []byte) error

Save - save data to a bucket unit

type SegmentDs

type SegmentDs struct {
	Size uint64
	Natt uint16
}

SegmentDs - the segment data structure

func GetShmDsByKey

func GetShmDsByKey(key uint32) (*SegmentDs, error)

GetShmDsByKey - get shm ds by the key

type SegmentHead

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

SegmentHead - the segment head of shm

type SegmentOption

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

SegmentOption - the segment option for new

func (*SegmentOption) AddBucket

func (opt *SegmentOption) AddBucket(count uint32, bytes uint32)

AddBucket - add a bucket type

func (*SegmentOption) PrintBucket

func (opt *SegmentOption) PrintBucket() string

PrintBucket - print the bucket info

Jump to

Keyboard shortcuts

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