//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
namespace System.Threading
{
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Microsoft.Bartok.Runtime;
///
/// A monitor is used for synchronization. Only a single thread can
/// hold the monitor at any given time.
///
// Because Monitors are encoded in the MultiUseWord payload,
// they must be 8-byte aligned
[StructAlign(8)]
[NoCCtor]
public sealed partial class Monitor {
///
/// Attempt to enter the monitor, blocking until it is held.
///
[Intrinsic]
public static extern void Enter(Object obj);
[RequiredByBartok("Enter gets lowered to this")]
private static void EnterImpl(Object obj) {
Monitor monitor = GetMonitorFromObject(obj);
monitor.Enter();
}
///
/// Exit the monitor.
///
[Intrinsic]
public static extern void Exit(Object obj);
[RequiredByBartok("Exit gets lowered to this")]
public static void ExitImpl(Object obj) {
Monitor monitor = GetMonitorFromObject(obj);
monitor.Exit();
}
}
}