haxe/src/haxe/EntryPoint.cs
// Generated by Haxe 4.3.7

#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe {
	public class EntryPoint : global::haxe.lang.HxObject {
		
		static EntryPoint() {
			global::haxe.EntryPoint.mutex = new global::sys.thread.Mutex();
			global::haxe.EntryPoint.mainThread = ((global::sys.thread._Thread.HaxeThread) (global::sys.thread._Thread.HaxeThread.current()) );
			global::haxe.EntryPoint.pending = new global::Array<object>();
			global::haxe.EntryPoint.threadCount = 0;
		}
		
		
		public EntryPoint(global::haxe.lang.EmptyObject empty) {
		}
		
		
		public EntryPoint() {
			global::haxe.EntryPoint.__hx_ctor_haxe_EntryPoint(this);
		}
		
		
		protected static void __hx_ctor_haxe_EntryPoint(global::haxe.EntryPoint __hx_this) {
		}
		
		
		public static global::sys.thread.Mutex mutex;
		
		public static global::sys.thread._Thread.HaxeThread mainThread;
		
		public static global::Array<object> pending;
		
		public static int threadCount;
		
		public static void wakeup() {
		}
		
		
		public static void runInMainThread(global::haxe.lang.Function f) {
			global::sys.thread._Thread.Thread_Impl_.get_events(global::haxe.EntryPoint.mainThread).run(f);
		}
		
		
		public static void addThread(global::haxe.lang.Function f) {
			global::haxe.EntryPoint.mutex.acquire();
			global::haxe.EntryPoint.threadCount++;
			global::haxe.EntryPoint.mutex.release();
			global::sys.thread._Thread.Thread_Impl_.get_events(global::haxe.EntryPoint.mainThread).promise();
			global::sys.thread._Thread.Thread_Impl_.create(new global::haxe.EntryPoint_addThread_79__Fun(f));
		}
		
		
		public static double processEvents() {
			unchecked {
				return ((double) (-1) );
			}
		}
		
		
		public static void run() {
		}
		
		
	}
}



#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe {
	public class EntryPoint_addThread_87__Fun : global::haxe.lang.Function {
		
		public EntryPoint_addThread_87__Fun() : base(0, 0) {
		}
		
		
		public static global::haxe.EntryPoint_addThread_87__Fun __hx_current;
		
		public override object __hx_invoke0_o() {
			return null;
		}
		
		
	}
}



#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe {
	public class EntryPoint_addThread_79__Fun : global::haxe.lang.Function {
		
		public EntryPoint_addThread_79__Fun(global::haxe.lang.Function f) : base(0, 0) {
			this.f = f;
		}
		
		
		public override object __hx_invoke0_o() {
			this.f.__hx_invoke0_o();
			global::haxe.EntryPoint.mutex.acquire();
			global::haxe.EntryPoint.threadCount--;
			if (( global::haxe.EntryPoint.threadCount == 0 )) {
				global::haxe.EntryPoint.wakeup();
			}
			
			global::haxe.EntryPoint.mutex.release();
			global::sys.thread._Thread.Thread_Impl_.get_events(global::haxe.EntryPoint.mainThread).runPromised(( (( global::haxe.EntryPoint_addThread_87__Fun.__hx_current != null )) ? (global::haxe.EntryPoint_addThread_87__Fun.__hx_current) : (global::haxe.EntryPoint_addThread_87__Fun.__hx_current = ((global::haxe.EntryPoint_addThread_87__Fun) (new global::haxe.EntryPoint_addThread_87__Fun()) )) ));
			return null;
		}
		
		
		public global::haxe.lang.Function f;
		
	}
}