Skip to content

Tasks are still running on main thread #4

Description

@daBlesr

Hello, I tried creating computationally intensive tasks on wasm web, on separate threads using:

use std::thread;
use async_task::Task;
use bevy::tasks::futures::{check_ready, now_or_never};
use web_task::{spawn};

let task: Task<Option<NavigationPath>> = spawn(async move {
  let current_thread = thread::current();
  info!(
      "Pathfinding is running on thread: name={:?}, id={:?}",
      current_thread.name(),
      current_thread.id()
  );
  let guard = obs_clone.read();
  if let Ok(obstacles) = guard.as_ref() {
      compute_path_towards(&*obstacles, pos, &target_clone, CELL_SIZE)
  } else {
      None
  }
});

but it keeps printing "main" thread. I was thinking the purpose of this library is to specifically that right? Am I doing it wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions