79717883

Date: 2025-07-28 21:14:59
Score: 0.5
Natty:
Report link

Use actix_web::rt::spawn(), which does not have a Send requirement, and runs the future on the current thread:

https://docs.rs/actix-web/latest/actix_web/rt/fn.spawn.html

Any other Send futures or tasks can be spawned into different threads, and any other non-Send (!Send) futures can be spawned on the same thread, they will cooperate to share execution time.

If you need a dedicated thread for a !Send future, you can create it manually using std::thread::Builder, then use Handle::block_on() to call actix_web::rt::spawn() to run the future locally on that thread.

Here is a similar answer that covers most of that:

https://stackoverflow.com/a/75387575/4970342

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: T2345