private static void Main() { // One-time initialization per application DotsRuntime.Initialize(); // Setup the global static string interning storage TempMemoryScope.EnterScope(); WordStorage.Initialize(); TempMemoryScope.ExitScope(); // A UnityInstance can exist per game state (there may potentially be more than one) var unity = UnityInstance.Initialize(); unity.OnTick = (double timestampInSeconds) => { var shouldContinue = unity.Update(timestampInSeconds); if (shouldContinue == false) { unity.Deinitialize(); } return(shouldContinue); }; // Anything which can come after EnterMainLoop must occur in an event because // on some platforms EnterMainLoop exits immediately and the application enters // an event-driven lifecycle. PlatformEvents.OnQuit += (object sender, QuitEvent evt) => { Shutdown(); }; PlatformEvents.OnSuspendResume += (object sender, SuspendResumeEvent evt) => { unity.Suspended = evt.Suspend; }; // Run RunLoop.EnterMainLoop(unity.OnTick); // DON'T CALL ANY CLEANUP HERE! }
public static void RunAll(RunLoop loop) { for (int x = 0; x < LENGTH; x++) { for(int y = 0; y<HEIGHT; y++) { if(loop(x,y)) return; } } }
protected async Task ConnectAndStartRunLoopAsync( Uri uri, Func <string, CancellationToken, Task> receive, CancellationTokenSource cts) { WasmDebuggerConnection conn = await SetupConnection(uri, cts.Token); conn.OnReadAsync = receive; _runLoop = new(new[] { new DevToolsQueue(conn) }, logger); _runLoop.RunLoopStopped += (sender, args) => RunLoopStopped?.Invoke(sender, args); _ = _runLoop.RunAsync(cts); }
void Start() { this.runLoop = BaseRunLoopBuilder.Build(); this.bornText = this.GetComponent <Text>("bornPeoplsText"); this.deadText = this.GetComponent <Text>("deadPeoplsText"); this.peoplsText = this.GetComponent <Text>("peoplsText"); var button = this.GetComponent <Button>("myButton"); button.onClick.AddListener(() => { print("step"); runLoop.Step(); this.Show(); }); }
private static void Main() { var unity = UnityInstance.Initialize(); unity.OnTick = () => { var shouldContinue = unity.Update(); if (shouldContinue == false) { unity.Deinitialize(); } return(shouldContinue); }; RunLoop.EnterMainLoop(unity.OnTick); }
protected async Task RunLoopAsync(WasmDebuggerConnection ideConn, WasmDebuggerConnection browserConn, CancellationTokenSource cts) { try { this.ide = new DevToolsQueue(ideConn); this.browser = new DevToolsQueue(browserConn); ideConn.OnReadAsync = ProcessIdeMessage; browserConn.OnReadAsync = ProcessBrowserMessage; _runLoop = new(new[] { ide, browser }, logger); _runLoop.RunLoopStopped += RunLoopStopped; await _runLoop.RunAsync(cts); } finally { _runLoop?.Dispose(); _runLoop = null; } }
/// <summary> Construct a new QueuedExecutor that uses /// the supplied Channel as its queue. /// <p> /// This class does not support any methods that /// reveal this queue. If you need to access it /// independently (for example to invoke any /// special status monitoring operations), you /// should record a reference to it separately. /// </p> /// </summary> public QueuedExecutor(IChannel queue) { queue_ = queue; runLoop_ = new RunLoop(this); }
public RunLoopTaskScheduler(RunLoop runLoop, RunLoop.Priority priority) { _runLoop = runLoop; _priority = priority; }
public RunLoopSynchronizationContext(RunLoop runLoop) { _runLoop = runLoop; }
protected virtual void Dispose(bool disposing) { _runLoop?.Dispose(); _runLoop = null; }
private MainThread() { _runLoop = new RunLoop(); Motor.DefaultMotor.attachMachine(this); }