Skip to content

Multi Shared Lock

Randgalt edited this page Oct 10, 2011 · 4 revisions

Description

A container that manages multiple locks as a single entity. When acquire() is called, all the locks are acquired. If that fails, any paths that were acquired are released. Similarly, when release() is called, all locks are released (failures are ignored).

Participating Classes

  • InterProcessMultiLock
  • InterProcessLock

Usage

Creating a InterProcessMultiLock

public InterProcessMultiLock(List<InterProcessLock> locks)
Creates a multi lock of any type of inter process lock
Parameters:
locks - the locks

public InterProcessMultiLock(CuratorFramework client,
List<String> paths)
Creates a multi lock of InterProcessMutexes
Parameters:
client - client
paths - list of paths to manage in the order that they are to be locked

General Usage

The usage is the same as for Shared Lock. However, When acquire() is called, all the locks are acquired. If that fails, any paths that were acquired are released. Similarly, when release() is called, all locks are released (failures are ignored).

Clone this wiki locally