org.apache.ignite.internal.util

## Class StripedCompositeReadWriteLock

- java.lang.Object
- - org.apache.ignite.internal.util.StripedCompositeReadWriteLock

All Implemented Interfaces:
  ReadWriteLock

    public class StripedCompositeReadWriteLock
    extends Object
    implements ReadWriteLock

ReadWriteLock with striping mechanics. Compared to `ReentrantReadWriteLock` it has slightly improved performance of `ReadWriteLock.readLock()` operations at the cost of `ReadWriteLock.writeLock()` operations and memory consumption. It also supports reentrancy semantics like `ReentrantReadWriteLock`.

### Constructor Summary

Constructors
Constructor and Description
`StripedCompositeReadWriteLock(int concurrencyLvl)` Creates a new instance with given concurrency level.

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `getReadHoldCount()` Queries the number of reentrant read holds on this lock by the current thread.
`boolean` `isWriteLockedByCurrentThread()` Queries if the write lock is held by the current thread.
`@NotNull Lock` `readLock()`
`@NotNull Lock` `writeLock()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### StripedCompositeReadWriteLock

    public StripedCompositeReadWriteLock(int concurrencyLvl)

Creates a new instance with given concurrency level.

Parameters:
  `concurrencyLvl` - Number of internal read locks.

### Method Detail

#### readLock

    @NotNull
    public @NotNull Lock readLock()

Specified by:
  `readLock` in interface `ReadWriteLock`

#### writeLock

    @NotNull
    public @NotNull Lock writeLock()

Specified by:
  `writeLock` in interface `ReadWriteLock`

#### isWriteLockedByCurrentThread

    public boolean isWriteLockedByCurrentThread()

Queries if the write lock is held by the current thread.

Returns:
  `true` if the current thread holds the write lock and `false` otherwise

#### getReadHoldCount

    public int getReadHoldCount()

Queries the number of reentrant read holds on this lock by the current thread. A reader thread has a hold on a lock for each lock action that is not matched by an unlock action.

Returns:
  the number of holds on the read lock by the current thread, or zero if the read lock is not held by the current thread

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021