mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Comptime compat
This commit is contained in:
parent
1223395a01
commit
bbb97d1490
1 changed files with 16 additions and 6 deletions
|
@ -18,11 +18,13 @@ namespace System.Threading
|
|||
|
||||
public this()
|
||||
{
|
||||
if (!Compiler.IsComptime)
|
||||
mCritSect = Platform.BfpCritSect_Create();
|
||||
}
|
||||
|
||||
public ~this()
|
||||
{
|
||||
if (!Compiler.IsComptime)
|
||||
Platform.BfpCritSect_Release(mCritSect);
|
||||
}
|
||||
|
||||
|
@ -34,6 +36,7 @@ namespace System.Threading
|
|||
{
|
||||
MonitorLockInstance monitorLockInstance;
|
||||
monitorLockInstance.mMonitor = this;
|
||||
if (!Compiler.IsComptime)
|
||||
Platform.BfpCritSect_Enter(mCritSect);
|
||||
return monitorLockInstance;
|
||||
}
|
||||
|
@ -44,6 +47,7 @@ namespace System.Threading
|
|||
/// multiple Enters which have not all be Exited.
|
||||
public void Exit()
|
||||
{
|
||||
if (!Compiler.IsComptime)
|
||||
Platform.BfpCritSect_Leave(mCritSect);
|
||||
}
|
||||
|
||||
|
@ -51,14 +55,20 @@ namespace System.Threading
|
|||
/// @return true if the monitor was entered
|
||||
public bool TryEnter()
|
||||
{
|
||||
if (!Compiler.IsComptime)
|
||||
return Platform.BfpCritSect_TryEnter(mCritSect, 0);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Blocks up to a timeout, or if millisecondsTimeout is -1, will wait forever.
|
||||
/// @return true if the monitor was entered
|
||||
public bool TryEnter(int millisecondsTimeout)
|
||||
{
|
||||
if (!Compiler.IsComptime)
|
||||
return Platform.BfpCritSect_TryEnter(mCritSect, (int32)millisecondsTimeout);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int32 MillisecondsTimeoutFromTimeSpan(TimeSpan timeout)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue