ensuring threading is working
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 19 Oct 2021 02:42:01 +0000 (21:42 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 19 Oct 2021 02:42:01 +0000 (21:42 -0500)
src/sim.onyx

index e7b3b2b3314e44154b7535adab7eb3799448e67a..1bf9456b49db50edcf462cab109c339fffb400e5 100644 (file)
@@ -15,6 +15,18 @@ package main
 main :: (args) => {
     ouit.init("main_canvas", handle_event, update, draw);
     ouit.start();
+
+    t: thread.Thread;
+    thread.spawn(^t, null, (_) => {
+        i := 0;
+        while true {
+            use package core.intrinsics.atomics
+            i += 1;
+
+            __atomic_wait(cast(^i32) null, 0, 1000000000);
+            printf("Count: {}\n", i);
+        }
+    });
 }
 
 x: f32 = 0;
@@ -51,7 +63,7 @@ draw :: () {
     gl.clearColor(.1, .1, .1, 1);
     gl.clear(gl.COLOR_BUFFER_BIT);
 
-    gfx.rect(.{ x, y }, .{ 50, 50 }, .{ 1, 1, 1 });
+    gfx.rect(.{ x, y }, .{ 50, 50 }, .{ 1, 0, 0 });
 
     gfx.flush();
 }
\ No newline at end of file