LockHolder

class LockHolder(val pid: Long, val startedAt: Instant)

The process a LOCK file names as its holder.

The start time is not decoration, and it is the reason this is a class rather than a Long. Operating systems reuse process ids, so a pid on its own can name a process that has nothing to do with the store — and reporting that pid to a user, who may then kill it, is worse than reporting nothing. isRunning is true only when a live process carries this id and started at this instant, which is what makes the claim safe to act on.

A record can also be stale in the other direction: a LOCK left behind by a crash still names the dead process, while the operating system released its lock long ago. That case reads as isRunning == false, and it means the file is a leftover rather than that anything is wrong — the next open takes the lock normally.

Constructors

Link copied to clipboard
constructor(pid: Long, startedAt: Instant)

Properties

Link copied to clipboard

Whether a process with this id is running and started at startedAt.

Link copied to clipboard
val pid: Long

the operating-system process id the lock file recorded.

Link copied to clipboard

when that process started, as the holder's own runtime reported it.

Functions

Link copied to clipboard
open override fun toString(): String