Documentation
¶
Index ¶
- Constants
- func AbsTimeoutToTimeSpec(timeout time.Duration) *unix.Timespec
- func CallTimeout(f func(time.Duration) bool, timeout time.Duration)
- func FlagsForAccess(flag int) int
- func FlagsForOpen(flag int) int
- func IsInterruptedSyscallErr(err error) bool
- func IsTimeoutErr(err error) bool
- func NewTimeoutError(op string) error
- func OpenOrCreate(creator func(bool) error, flag int) (bool, error)
- func SyscallErrHasCode(err error, code syscall.Errno) bool
- func SyscallNameFromErr(err error) string
- func TimeoutToTimeSpec(timeout time.Duration) *unix.Timespec
- func TmpFilename(name string) string
- func UninterruptedSyscall(f func() error) error
- func UninterruptedSyscallTimeout(f func(time.Duration) error, timeout time.Duration) error
- type Destroyer
- type Key
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 )
Variables ¶
This section is empty.
Functions ¶
func AbsTimeoutToTimeSpec ¶
AbsTimeoutToTimeSpec converts given timeout value to absulute value of unix.Timespec.
func CallTimeout ¶
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 ¶
FlagsForAccess extracts os.O_RDONLY, os.O_WRONLY, os.O_RDWR, and O_NONBLOCK flag values.
func FlagsForOpen ¶
FlagsForOpen extracts os.O_CREATE and os.O_EXCL flag values.
func IsInterruptedSyscallErr ¶
IsInterruptedSyscallErr returns true, if the given error is a syscall.EINTR error.
func IsTimeoutErr ¶
IsTimeoutErr returns true, if the given error is a temporary syscall error.
func NewTimeoutError ¶
NewTimeoutError returns new syscall error with EAGAIN code.
func OpenOrCreate ¶
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 ¶
SyscallErrHasCode returns true, if given error is a syscall error with given code.
func SyscallNameFromErr ¶
SyscallNameFromErr returns name of a syscall from a syscall errror.
func TimeoutToTimeSpec ¶
TimeoutToTimeSpec converts given timeout value to relative value of unix.Timespec.
func TmpFilename ¶
TmpFilename returns a full path for a temporary file with the given name.
func UninterruptedSyscall ¶
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 ¶
UninterruptedSyscallTimeout runs a function in a loop. It acts like UninterruptedSyscall, however, before every run it recalculates timeout value according to the passed time.