Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct { Lockfile string // contains filtered or unexported fields }
Lock prevents code to run at the same time by using a lockfile
func (*Lock) ForceAcquire ¶ added in v0.9.2
ForceAcquire returns true if the lock was successfully set.
If a lock file already exists, it reads the PID of the supposedly running process and check if it's still running. If there no more process with this PID, it will try to delete the lock, then recreate a new lock.
func (*Lock) HasLocked ¶ added in v0.9.2
HasLocked check this instance (and only this one) has locked the file
func (*Lock) SetPID ¶ added in v0.9.2
SetPID writes down the PID in the lock file. You can run the method as many times as you want when the PID changes
func (*Lock) TryAcquire ¶
TryAcquire returns true if the lock was successfully set. It returns false if a lock already exists
Click to show internal directories.
Click to hide internal directories.