From fd214e043e04ff388fde7c88702a16e108cf72bc Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 18 Oct 2021 11:49:52 -0500 Subject: [PATCH] changes --- site/js/decompiler.js | 4 +--- src/app/app.onyx | 18 +++++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/site/js/decompiler.js b/site/js/decompiler.js index 56024b4..6cfa4cc 100644 --- a/site/js/decompiler.js +++ b/site/js/decompiler.js @@ -18,9 +18,7 @@ window.ONYX_MODULES.push({ }, alert: function(strptr, strlen) { - const decoder = new TextDecoder(); - const data = new Uint8Array(window.ONYX_MEMORY.buffer, strptr, strlen); - const str = decoder.decode(data); + const str = onyx_decode_text(strptr, strlen); window.alert(str); }, diff --git a/src/app/app.onyx b/src/app/app.onyx index e86e6b6..c7b4d83 100644 --- a/src/app/app.onyx +++ b/src/app/app.onyx @@ -198,25 +198,29 @@ init :: () { use package core.intrinsics.atomics - t, t2: thread.Thread; - thread.spawn(^t, (_: ^i32) { + #persist #thread_local t : thread.Thread; + #persist #thread_local t2 : thread.Thread; + #persist barrier : sync.Barrier; + sync.barrier_init(^barrier, 2); + + thread.spawn(^t, null, (_: ^i32) { printf("Hello from another thread!\n"); for i: 1000 { - __atomic_wait(_, 0, 1000000000); + sync.barrier_wait(^barrier); printf("Hello from another thread! {}\n", i); } + }); - }, null); - - thread.spawn(^t2, (_: ^i32) { + thread.spawn(^t2, null, (_: ^i32) { i := 1; while true { i *= 2; __atomic_wait(_, 0, 1000000000); + sync.barrier_wait(^barrier); debug_log(.Warning, "Debug message: {}\n", i); } - }, null); + }); } handle_event :: (event: ^events.Event) { -- 2.25.1