ipcm

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 7 Imported by: 1

README

ipcm

What is it?

A Go library that provides tooling for orchestrating inter-process communication (IPC) on different operating systems.

API

Mutex

The primary feature of this library is a Mutex for communicating exclusion across process boundaries. It functions in a similar manner to sync.Mutex in that a call to Lock() will block until the mutex is locked. Once locked, the Mutex owner is responsible for releasing control by calling Unlock().

Documentation

Overview

Package ipcm (Inter Process Communication Mutex) provides tooling for orchestrating inter-process communication (IPC) on different operating systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigureError

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

func (*ConfigureError) Error

func (o *ConfigureError) Error() string

func (*ConfigureError) PathNotFullyQualified

func (o *ConfigureError) PathNotFullyQualified() bool

func (*ConfigureError) ResourceNotSpecified

func (o *ConfigureError) ResourceNotSpecified() bool

type LockError

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

func (*LockError) Error

func (o *LockError) Error() string

func (*LockError) FailedToCreateParentDirectory

func (o *LockError) FailedToCreateParentDirectory() bool

func (*LockError) FailedToCreated

func (o *LockError) FailedToCreated() bool

func (*LockError) SyncMutexLockTimedOut

func (o *LockError) SyncMutexLockTimedOut() bool

func (*LockError) SystemCallFailed

func (o *LockError) SystemCallFailed() bool

func (*LockError) SystemMutexLockTimedOut

func (o *LockError) SystemMutexLockTimedOut() bool

func (*LockError) WindowsDllLoadFailed

func (o *LockError) WindowsDllLoadFailed() bool

func (*LockError) WindowsProcedureLoadFailed

func (o *LockError) WindowsProcedureLoadFailed() bool

type Mutex

type Mutex interface {
	// Lock locks the mutex.
	//
	// Be advised that this call will block until the mutex can be locked.
	// If an error occurs while trying to lock the Mutex, the method will
	// keep trying. Any underlying errors that occur when locking the OS
	// mutex are hidden from the caller when using this method.
	Lock()

	// TimedTryLock attempts to lock the Mutex within the specified
	// timeout. A non-nil error is returned when the Mutex cannot be
	// locked in time.
	TimedTryLock(time.Duration) error

	// Unlock unlocks the Mutex. Like sync.Mutex, this call will panic
	// if the Mutex is already unlocked.
	Unlock()
}

Mutex is a thread-safe object that functions in a similar manner to sync.Mutex, only it works across process boundaries. It can be used to orchestrate the execution of threads between different processes in the same way that a sync.Mutex controls access to data between multiple go routines.

In other words, when one routine locks the mutex, all other routines within the current process and external process(es) will block if they attempt to lock the mutex.

func NewMutex

func NewMutex(config MutexConfig) (Mutex, error)

NewMutex creates a new Mutex.

type MutexConfig

type MutexConfig struct {
	// Resource is an object that exists outside of the running process.
	// Other processes must use the same value to reference the Mutex.
	//
	// On unix systems, this must be a string representing a fully
	// qualified file path.
	// For example:
	//  /var/myapplication/lock
	//
	// On Windows, this is a string representing the name of a Mutex
	// object. The string can consist of any character except backslash.
	// For more information, refer to the 'CreateMutexW' API documentation:
	//  https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-createmutexw
	// For example:
	//  myapplication
	Resource string
}

MutexConfig configures a Mutex.

Directories

Path Synopsis
cmd
testharness command

Jump to

Keyboard shortcuts

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