go-ipc: bitbucket.org/avd/go-ipc/internal/common Index | Files

package common

import "bitbucket.org/avd/go-ipc/internal/common"

Index

Package Files

common.go common_unix.go

Constants

const (
    // IpcCreate flag tells a function to create an object if key is nonexistent.
    IpcCreate = 00001000
    // IpcExcl flag tells a function to create an object if key is nonexistent and fail if key exists.
    IpcExcl = 00002000
    // IpcNoWait flag tell a function to return error on wait.
    IpcNoWait = 00004000

    // IpcRmid flag tells a function to remove resource.
    IpcRmid = 0
    // IpcSet flag tells a function to set ipc_perm options.
    IpcSet = 1
    // IpcStat flag tells a function to get ipc_perm options.
    IpcStat = 2
    // IpcInfo flag tells a function to retrieve information about an object.
    IpcInfo = 3
)
const (
    // O_NONBLOCK flag tell some functions not to block.
    // Its value does not interfere with O_* constants from 'os' package.
    O_NONBLOCK = syscall.O_NONBLOCK
)

func AbsTimeoutToTimeSpec Uses

func AbsTimeoutToTimeSpec(timeout time.Duration) *unix.Timespec

AbsTimeoutToTimeSpec converts given timeout value to absulute value of unix.Timespec.

func CallTimeout Uses

func CallTimeout(f func(time.Duration) bool, timeout time.Duration)

CallTimeout calls f in a loop allowing it to run for at least 'timeout'. It calls f, measuring its runtime:

if f returned false, or its cumulative runtime exceeded timeout, CallTimeout returns.
otherwise CallTimeout subtracts runtime from timeout anf calls 'f' with the updated value.

func FlagsForAccess Uses

func FlagsForAccess(flag int) int

FlagsForAccess extracts os.O_RDONLY, os.O_WRONLY, os.O_RDWR, and O_NONBLOCK flag values.

func FlagsForOpen Uses

func FlagsForOpen(flag int) int

FlagsForOpen extracts os.O_CREATE and os.O_EXCL flag values.

func IsInterruptedSyscallErr Uses

func IsInterruptedSyscallErr(err error) bool

IsInterruptedSyscallErr returns true, if the given error is a syscall.EINTR error.

func IsTimeoutErr Uses

func IsTimeoutErr(err error) bool

IsTimeoutErr returns true, if the given error is a temporary syscall error.

func NewTimeoutError Uses

func NewTimeoutError(op string) error

NewTimeoutError returns new syscall error with EAGAIN code.

func OpenOrCreate Uses

func OpenOrCreate(creator func(bool) error, flag int) (bool, error)

OpenOrCreate performs open/create file operation according to the given mode. It allows to find out if the object was opened or created.

creator is the function which performs actual operation:
	if is called with 'true', if it must create an object, and with false otherwise.
	it must return an 'not exists error' if the param is false, and the object does not exist.
	it must return an 'already exists error' if the param is true, and the object already exists.
flag is the combination of open flags from os package.
	If flag == os.O_CREATE, OpenOrCreate makes several attempts to open or create an object,
	and analyzes the return error. It tries to open the object first.

func SyscallErrHasCode Uses

func SyscallErrHasCode(err error, code syscall.Errno) bool

SyscallErrHasCode returns true, if given error is a syscall error with given code.

func SyscallNameFromErr Uses

func SyscallNameFromErr(err error) string

SyscallNameFromErr returns name of a syscall from a syscall errror.

func TimeoutToTimeSpec Uses

func TimeoutToTimeSpec(timeout time.Duration) *unix.Timespec

TimeoutToTimeSpec converts given timeout value to relative value of unix.Timespec.

func TmpFilename Uses

func TmpFilename(name string) string

TmpFilename returns a full path for a temporary file with the given name.

func UninterruptedSyscall Uses

func UninterruptedSyscall(f func() error) error

UninterruptedSyscall runs a function in a loop. If an error, returned by the function is a syscall.EINTR error, it runs the function again. Otherwise, it returns the error.

func UninterruptedSyscallTimeout Uses

func UninterruptedSyscallTimeout(f func(time.Duration) error, timeout time.Duration) error

UninterruptedSyscallTimeout runs a function in a loop. It acts like UninterruptedSyscall, however, before every run it recalculates timeout value according to the passed time.

type Destroyer Uses

type Destroyer interface {
    Destroy() error
}

Destroyer is an object which can be permanently removed.

type Key Uses

type Key uint64

Key is an unsigned integer value considered to be unique for a unique name.

func KeyForName Uses

func KeyForName(name string) (Key, error)

KeyForName generates a key for given path.

Package common imports 6 packages (graph) and is imported by 4 packages. Updated 2019-05-07. Refresh now. Tools for package owners.