-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure that wasm binaries are copied correctly, move event loop execu…
…tion into the quickjs_with_ctx
- Loading branch information
Showing
12 changed files
with
26 additions
and
32 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 18 additions & 2 deletions
20
...stable/commands/compile/wasm_binary/rust/stable_canister_template/src/quickjs_with_ctx.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
use crate::CONTEXT_REF_CELL; | ||
use rquickjs::Ctx; | ||
|
||
pub fn quickjs_with_ctx<F, R>(f: F) -> R | ||
pub fn quickjs_with_ctx<F, R>(callback: F) -> R | ||
where | ||
F: FnOnce(Ctx) -> R, | ||
{ | ||
CONTEXT_REF_CELL.with(|context_ref_cell| { | ||
let context_ref = context_ref_cell.borrow(); | ||
let context = context_ref.as_ref().unwrap(); | ||
|
||
context.with(f) | ||
context.with(|ctx| { | ||
let result = callback(ctx.clone()); | ||
|
||
run_event_loop(ctx); | ||
|
||
result | ||
}) | ||
}) | ||
} | ||
|
||
fn run_event_loop(ctx: rquickjs::Ctx) { | ||
loop { | ||
let result = ctx.execute_pending_job(); | ||
|
||
if result == false { | ||
break; | ||
} | ||
} | ||
} |