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).

Tipo
final class
Espacio de nombres
System.Reflection
Ensamblado
System.Core
Acceso
internal, final
Archivo fuente
Reflection.ant

Herencia

Clases base
Any Reentrant

Constructores

new()
#

Métodos

Enter()
#
Exit()
#

Miembros privados e internos (3)

readonly Mutex mutex
#

private

i32 owner
#

private

i32 depth
#

private

Miembros heredados (5)

Código fuente

Reentrant en Antril, descompilado a partir de su Larva HIR.

System.Reflection.Reentrant.ant
// 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();
				}
			}
	}
}
Esc