(acquire-for! dir sleep-interval _on-deposed)Acquires a virtual, exclusive lease to write on dir. Implementation:
Acquires a virtual, exclusive lease to write on dir. Implementation: - Deletes the lock file of the previous owner, if any. Deletes the 'lock' directory in dir. - Creates the 'lock' directory atomically (via rename) in dir with our own lock file in it. - Starts to periodically refresh the lease (rename our lock file to make sure it still exists). Cooperatively and definitively yields the lease when some other owner deletes our lock file. Returns the lease (an opaque handle) to be used with the other fns in this namespace. Calls on-deposed when we gain knowledge that some other owner (normally a different machine) has taken over the lease.
(check! my-lease)Throws an exception with a helpful message in these situations:
Throws an exception with a helpful message in these situations: - The lock file has been deleted (normally by another owner taking over). - The last attempt to refresh the lease (rename our lock file) has failed and we cannot be certain whether the file still exists or has been deleted.
(dir lease)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |