//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Threading;

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

/// <summary>
/// Threading monitor helpers
/// </summary>
public static class monitor {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static void PulseAndWait( object obj )
{
   Monitor.Pulse( obj );
   Monitor.Wait( obj );
}

public static void WaitAndPulse( object obj )
{
   Monitor.Wait( obj );
   Monitor.Pulse( obj );
}

public static void PulseWaitAndPulse( object obj )
{
   Monitor.Pulse( obj );
   Monitor.Wait( obj );
   Monitor.Pulse( obj );
}

//--------------------------------------------------------------------------------------------------

public static void LockWait( object obj )
{
   lock ( obj )
      Monitor.Wait( obj );
}

public static void LockPulse( object obj )
{
   lock ( obj )
      Monitor.Pulse( obj );
}

public static void LockPulseAndWait( object obj )
{
   lock ( obj ) {
      Monitor.Pulse( obj );
      Monitor.Wait( obj );
   }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // monitor

} // user_rtx (.wasm)
