Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/juju/fslock

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/juju/fslock

  • v0.0.0-20160525022230-4d5c94c67b4b
  • Source
  • Go
  • Socket score

Version published
Created
Source

fslock GoDoc

fslock provides a cross-process mutex based on file locks that works on windows and *nix platforms.

fslock

image: public domain (don't ask)

fslock relies on LockFileEx on Windows and flock on *nix systems. The timeout feature uses overlapped IO on Windows, but on *nix platforms, timing out requires the use of a goroutine that will run until the lock is acquired, regardless of timeout. If you need to avoid this use of goroutines, poll TryLock in a loop.

Variables

var ErrLocked error = trylockError("fslock is already locked")

ErrLocked indicates TryLock failed because the lock was already locked.

var ErrTimeout error = timeoutError("lock timeout exceeded")

ErrTimeout indicates that the lock attempt timed out.

type Lock

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

Lock implements cross-process locks using syscalls.

func New

func New(filename string) *Lock

New returns a new lock around the given file.

func (*Lock) Lock

func (l *Lock) Lock() error

Lock locks the lock. This call will block until the lock is available.

func (*Lock) LockWithTimeout

func (l *Lock) LockWithTimeout(timeout time.Duration) error

LockWithTimeout tries to lock the lock until the timeout expires. If the timeout expires, this method will return ErrTimeout.

func (*Lock) TryLock

func (l *Lock) TryLock() error

TryLock attempts to lock the lock. This method will return ErrLocked immediately if the lock cannot be acquired.

func (*Lock) Unlock

func (l *Lock) Unlock() error

Unlock unlocks the lock.

FAQs

Package last updated on 25 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc