Skip to content

Commit

Permalink
Make the return type of the main empty
Browse files Browse the repository at this point in the history
  • Loading branch information
temeddix committed Jun 17, 2024
1 parent 7168842 commit 088ec56
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions rust_crate/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct DartSignal<T> {
#[cfg(not(target_family = "wasm"))]
pub fn start_rust_logic<F>(main_future: F) -> Result<()>
where
F: Future + Send + 'static,
F: Future<Output = ()> + Send + 'static,
{
start_rust_logic_real(main_future)
}
Expand All @@ -39,7 +39,7 @@ where
#[cfg(target_family = "wasm")]
pub fn start_rust_logic<F>(main_future: F) -> Result<()>
where
F: Future + 'static,
F: Future<Output = ()> + 'static,
{
start_rust_logic_real(main_future)
}
Expand Down
6 changes: 2 additions & 4 deletions rust_crate/src/interface_os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static SHUTDOWN_SENDER: ShutdownSenderLock = OnceLock::new();

pub fn start_rust_logic_real<F>(main_future: F) -> Result<()>
where
F: Future + Send + 'static,
F: Future<Output = ()> + Send + 'static,
{
// Enable backtrace output for panics.
#[cfg(debug_assertions)]
Expand Down Expand Up @@ -68,9 +68,7 @@ where
{
let tokio_runtime = Builder::new_current_thread().enable_all().build()?;
thread::spawn(move || {
tokio_runtime.spawn(async {
main_future.await;
});
tokio_runtime.spawn(main_future);
tokio_runtime.block_on(shutdown_receiver);
// Dropping the tokio runtime makes it shut down.
drop(tokio_runtime);
Expand Down
6 changes: 2 additions & 4 deletions rust_crate/src/interface_web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use wasm_bindgen_futures::spawn_local;

pub fn start_rust_logic_real<F>(main_future: F) -> Result<()>
where
F: Future + 'static,
F: Future<Output = ()> + 'static,
{
// Add kind description for panics.
#[cfg(debug_assertions)]
Expand All @@ -17,9 +17,7 @@ where
}

// Run the main function.
spawn_local(async {
main_future.await;
});
spawn_local(main_future);

Ok(())
}
Expand Down

0 comments on commit 088ec56

Please sign in to comment.