final class · System.Reflection
Reentrant
final class Reentrant
A lock that the thread holding it may take again (the slow path of typeof may describe other types meanwhile).
- Kind
- final class
- Namespace
- System.Reflection
- Assembly
- System.Core
- Access
- internal, final
- Source file
Reflection.ant
Inheritance
- Base classes
-
AnyReentrant
Constructors
new()
#
Methods
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
Reentrant as Antril, decompiled from its Larva HIR.
// System.Reflection.Reentrant — System.Core (decompiled from Larva HIR)
import System.Threading;
into namespace System.Reflection
{
/// A lock that the thread holding it may take again (the slow path of `typeof` may describe other types meanwhile).
final class Reentrant
{
readonly Mutex mutex;
i32 owner;
i32 depth;
public:
new()
{
mutex = new Mutex();
}
Enter()
{
i32 me = Thread.CurrentId;
if (owner == me && depth > 0)
{
depth++;
return;
}
mutex.Lock();
owner = me;
depth = 1;
}
Exit()
{
depth--;
if (depth == 0)
{
owner = 0;
mutex.Unlock();
}
}
}
}