Skip to content

Commit

Permalink
Add display worker message
Browse files Browse the repository at this point in the history
  • Loading branch information
1whatleytay committed Sep 10, 2024
1 parent 650fa5d commit 109100f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 70 deletions.
107 changes: 54 additions & 53 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ base64 = "0.21.5"

saturn_backend = { path = "../src-backend" }
titan = { git = "https://github.com/1whatleytay/titan.git", branch = "main" }
async-trait = "0.1.82"

[features]
default = [ "custom-protocol" ]
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn swap<Listen: ListenResponder + Send + 'static, Track: Tracker<SectionMemo
keyboard: Arc<Mutex<KeyboardState>>,
console: Box<dyn ConsoleHandler + Send + Sync>,
midi: Box<dyn MidiHandler + Send + Sync>,
time: Box<dyn TimeHandler + Send + Sync>,
time: Arc<dyn TimeHandler + Send + Sync>,
) {
if let Some(state) = pointer.as_ref() {
state.pause();
Expand All @@ -67,7 +67,7 @@ pub fn swap_watched<Mem: Memory + Send + 'static>(
keyboard: Arc<Mutex<KeyboardState>>,
console: Box<dyn ConsoleHandler + Send + Sync>,
midi: Box<dyn MidiHandler + Send + Sync>,
time: Box<dyn TimeHandler + Send + Sync>,
time: Arc<dyn TimeHandler + Send + Sync>,
) {
if let Some(state) = pointer.as_ref() {
state.pause();
Expand Down Expand Up @@ -98,7 +98,7 @@ pub fn configure_elf(

let console = forward_print(app_handle.clone());
let midi = Box::new(ForwardMidi::new(app_handle));
let time = Box::new(TokioTimeHandler::new());
let time = Arc::new(TokioTimeHandler::new());
let history = HistoryTracker::new(TIME_TRAVEL_HISTORY_SIZE);

let mut memory = SectionMemory::new();
Expand Down Expand Up @@ -155,7 +155,7 @@ pub fn configure_asm(

let console = forward_print(app_handle.clone());
let midi = Box::new(ForwardMidi::new(app_handle));
let time = Box::new(TokioTimeHandler::new());
let time = Arc::new(TokioTimeHandler::new());
let history = HistoryTracker::new(TIME_TRAVEL_HISTORY_SIZE);

let mut memory = SectionMemory::new();
Expand Down
16 changes: 4 additions & 12 deletions src-tauri/src/time.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use futures::channel::oneshot::Receiver;
use saturn_backend::syscall::TimeHandler;
use futures::channel::oneshot;
use tokio::time::sleep;
use async_trait::async_trait;

pub struct TokioTimeHandler { }

impl TokioTimeHandler {
pub fn new() -> Self { Self { } }
}

#[async_trait]
impl TimeHandler for TokioTimeHandler {
fn time(&self) -> Option<Duration> {
SystemTime::now().duration_since(UNIX_EPOCH).ok()
}

fn sleep(&self, duration: Duration) -> Receiver<()> {
let (sender, receiver) = oneshot::channel();

tokio::spawn(async move {
sleep(duration).await;

sender.send(())
});

receiver
async fn sleep(&self, duration: Duration) {
sleep(duration).await;
}
}
1 change: 0 additions & 1 deletion src-wasm/pack.sh

This file was deleted.

0 comments on commit 109100f

Please sign in to comment.