Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make async spawn take a closure #1072

Open
@NawfelBgh

Description

@NawfelBgh

Hello,

I'm posting this idea to many Rust async runtimes discussion threads in order to push for the alternative design of the task spawn API described by@matklad inhttps://matklad.github.io/2023/12/10/nsfw.html

// std::thread::spawnpubfnspawn<F,T>(f:F) ->JoinHandle<T>whereF:FnOnce() ->T +Send +'static,T:Send +'static{}// A hypothetical better async spawnpubfnspawn<F,Fut>(f:F) ->JoinHandle<Fut::Output>whereF:FnOnce() ->Fut +Send +'static,Fut:Future,Fut::Output:Send +'static{}

If you think that this is the right direction for rust to take, I suggest to do the following to arrive at the destination ASAP:

  1. change task spawn definition to one that takes a closure returning a future
  2. Provide a safe executor constructor that pins tasks to threads
  3. Make workstealing executors unsafe to construct... until the language developers "fix" this issue of entangling of Send with OS threads

What do you think?

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp