haxe/src/sys/thread/Lock.cs
// Generated by Haxe 4.3.7
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace sys.thread {
public class Lock : global::haxe.lang.HxObject {
public Lock(global::haxe.lang.EmptyObject empty) {
}
public Lock() {
global::sys.thread.Lock.__hx_ctor_sys_thread_Lock(this);
}
protected static void __hx_ctor_sys_thread_Lock(global::sys.thread.Lock __hx_this) {
unchecked {
__hx_this.releaseCount = 0;
__hx_this.waitCount = 1;
__hx_this.releaseEvent = new global::System.Threading.SemaphoreSlim(((int) (0) ), ((int) (2147483647) ));
__hx_this.lockObj = new global::haxe.lang.DynamicObject(new int[]{}, new object[]{}, new int[]{}, new double[]{});
{
}
}
}
public object lockObj;
public global::System.Threading.SemaphoreSlim releaseEvent;
public int waitCount;
public int releaseCount;
public virtual bool wait(global::haxe.lang.Null<double> timeout) {
unchecked {
lock(this.lockObj){
++ this.waitCount;
}
;
bool ok = default(bool);
if ( ! (timeout.hasValue) ) {
this.releaseEvent.Wait();
ok = true;
}
else {
double secondsLeft = (timeout).@value;
if (( secondsLeft <= 0 )) {
ok = this.releaseEvent.Wait(((int) (0) ));
}
else {
ok = this.releaseEvent.Wait(((int) (((int) (( secondsLeft * 1000 )) )) ));
}
}
if (ok) {
lock(this.lockObj){
++ this.releaseCount;
}
;
}
return ok;
}
}
public virtual void release() {
lock(this.lockObj){
this.releaseCount++;
this.releaseEvent.Release();
}
;
}
public override double __hx_setField_f(string field, int hash, double @value, bool handleProperties) {
unchecked {
switch (hash) {
case 293985672:
{
this.releaseCount = ((int) (@value) );
return @value;
}
case 127488538:
{
this.waitCount = ((int) (@value) );
return @value;
}
case 877441228:
{
this.lockObj = ((object) (@value) );
return @value;
}
default:
{
return base.__hx_setField_f(field, hash, @value, handleProperties);
}
}
}
}
public override object __hx_setField(string field, int hash, object @value, bool handleProperties) {
unchecked {
switch (hash) {
case 293985672:
{
this.releaseCount = ((int) (global::haxe.lang.Runtime.toInt(@value)) );
return @value;
}
case 127488538:
{
this.waitCount = ((int) (global::haxe.lang.Runtime.toInt(@value)) );
return @value;
}
case 1021796563:
{
this.releaseEvent = ((global::System.Threading.SemaphoreSlim) (@value) );
return @value;
}
case 877441228:
{
this.lockObj = ((object) (@value) );
return @value;
}
default:
{
return base.__hx_setField(field, hash, @value, handleProperties);
}
}
}
}
public override object __hx_getField(string field, int hash, bool throwErrors, bool isCheck, bool handleProperties) {
unchecked {
switch (hash) {
case 1491961287:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "release", 1491961287)) );
}
case 1324505717:
{
return ((global::haxe.lang.Function) (new global::haxe.lang.Closure(this, "wait", 1324505717)) );
}
case 293985672:
{
return this.releaseCount;
}
case 127488538:
{
return this.waitCount;
}
case 1021796563:
{
return this.releaseEvent;
}
case 877441228:
{
return this.lockObj;
}
default:
{
return base.__hx_getField(field, hash, throwErrors, isCheck, handleProperties);
}
}
}
}
public override double __hx_getField_f(string field, int hash, bool throwErrors, bool handleProperties) {
unchecked {
switch (hash) {
case 293985672:
{
return ((double) (this.releaseCount) );
}
case 127488538:
{
return ((double) (this.waitCount) );
}
case 877441228:
{
return ((double) (global::haxe.lang.Runtime.toDouble(this.lockObj)) );
}
default:
{
return base.__hx_getField_f(field, hash, throwErrors, handleProperties);
}
}
}
}
public override object __hx_invokeField(string field, int hash, object[] dynargs) {
unchecked {
switch (hash) {
case 1491961287:
{
this.release();
break;
}
case 1324505717:
{
return this.wait(global::haxe.lang.Null<object>.ofDynamic<double>(( (( dynargs.Length > 0 )) ? (dynargs[0]) : (null) )));
}
default:
{
return base.__hx_invokeField(field, hash, dynargs);
}
}
return null;
}
}
public override void __hx_getFields(global::Array<string> baseArr) {
baseArr.push("releaseCount");
baseArr.push("waitCount");
baseArr.push("releaseEvent");
baseArr.push("lockObj");
base.__hx_getFields(baseArr);
}
}
}