java.lang.Object
com.telenav.kivakit.core.thread.ReentrancyTracker
Checks a section of code for reentrancy.
Calling enter()
and exit()
(usually in a try / finally block to ensure consistency) marks a section
of code as potentially reentrant. If enter()
returns ReentrancyTracker.Reentrancy.ENTERED
, the code section is being
entered for the first time. If it returns ReentrancyTracker.Reentrancy.REENTERED
, then the code section is being reentered
recursively. In the same way, exit()
returns ReentrancyTracker.Reentrancy.EXITED
if the code section is being exited
for the last time, and ReentrancyTracker.Reentrancy.EXITED_REENTRY
otherwise. Within the code section, hasReentered()
will return true if the code is being executed a second time through direct or indirect recursion.
- Author:
- jonathanl (shibo)
-
Constructor Details
-
ReentrancyTracker
public ReentrancyTracker()
-
-
Method Details
-
enter
Enters a block of reentrant code.- Returns:
- True if the code section can be entered because it has not yet been entered. Reentrancy can also be
checked with
hasReentered()
.
-
exit
Exits a block of re-entrant code.- Returns:
- True if the code is exiting for the last time.
-
hasReentered
public boolean hasReentered()
-