Skip to content

Commit

Permalink
docs: update for 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Jul 5, 2024
1 parent 8c98fce commit 1c90a50
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe

## Unreleased

## 0.2.0

### Changed

- Updated to bevy 0.14

### Fixed

- Blocking example for web targets.

## 0.1.1

### fixed
### Fixed

- READMDE re-uploaded to correct [#10](https://github.com/loopystudios/bevy_async_task/issues/10).

Expand Down
17 changes: 4 additions & 13 deletions examples/blocking.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
use async_std::task::sleep;
use bevy::{app::PanicHandlerPlugin, log::LogPlugin, prelude::*};
use bevy_async_task::{AsyncTask, AsyncTaskRunner};
use std::time::Duration;

/// You can block with a task runner
fn system1(mut task_executor: AsyncTaskRunner<u32>) {
let result = task_executor.blocking_recv(async {
sleep(Duration::from_millis(1000)).await;
1
});
let result = task_executor.blocking_recv(async { 1 });
info!("Received {result}");
}

/// Or block on a task, without the need of a system parameter.
fn system2() {
let result = AsyncTask::new(async {
sleep(Duration::from_millis(1000)).await;
2
})
.blocking_recv();
let result = AsyncTask::new(async { 2 }).blocking_recv();
info!("Received {result}");
}

pub fn main() {
App::new()
.add_plugins((MinimalPlugins, LogPlugin::default(), PanicHandlerPlugin))
.add_systems(Update, system1)
.add_systems(Update, system2)
.add_systems(Startup, system2)
.add_systems(Startup, system1)
.run();
}
2 changes: 1 addition & 1 deletion examples/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::time::Duration;

/// Use a timeout
fn system() {
let _timeout = AsyncTask::<()>::pending()
AsyncTask::<()>::pending()
.with_timeout(Duration::from_millis(1000))
.blocking_recv()
.unwrap_err();
Expand Down

0 comments on commit 1c90a50

Please sign in to comment.