-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
None
Introduce a basic Lock implementation that does not allow reentrancy. A BasicLock has similar behaviours as those of a ReentrantLock apart from the reentrancy property. My reasons are:
- It is the most basic form of a Lock, and it is what most Lock usages are about. Currently, we only have ReentrantLock, which imposes an unnecessary reentrancy property for many usages.
- A non-recursive lock is easier to reason about, as Lock::lock can only transit the lock from the unlock state to the lock state, and Lock::unlock can only do the opposite. This is in contrast to ReentrantLock, of which a lock or an unlock invocation can have 2 possible state transitions. This easily makes reasoning about the operation of a ReentrantLock non-local.
- A non-recursive lock can be more performant since it does not have to take into consideration reentrancy.
- It is the most basic form of a Lock, and it is what most Lock usages are about. Currently, we only have ReentrantLock, which imposes an unnecessary reentrancy property for many usages.
- A non-recursive lock is easier to reason about, as Lock::lock can only transit the lock from the unlock state to the lock state, and Lock::unlock can only do the opposite. This is in contrast to ReentrantLock, of which a lock or an unlock invocation can have 2 possible state transitions. This easily makes reasoning about the operation of a ReentrantLock non-local.
- A non-recursive lock can be more performant since it does not have to take into consideration reentrancy.