Rust Async Working Group
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Reading notes: Context reactor hook Link to document: https://jblog.andbit.net/2022/12/28/context-reactor-hook/ ###### tags: `reading-club` Leave questions, observations, discussion topics below. --- ## Topic vincenzo: how it is possible use the reactor concept to acheive an asyn function that do not depend from the runtime? (I am missing soemthing) vincenzo: in the described case the reactor is an observer patter? that will notify when a future is ready to be pool? --- ## Rough Draft A while back [Justin posted a link to a rough draft](https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async/topic/Context.20reactor.20hook/near/321525974) of what the reactor hooks would look like: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=486b97ac681c5d6923a066ef9bcae1df --- eholk: Is there any potential for deadlocks when futures on different reactor systems have dependencies between them? > If an application instantiates multiple futures that each require different reactors, and each reactor requires special behavior in the execution thread, then only one reactor would “win”. Futures requiring any of the other reactors would be expected to fail, for example by resolving to an error or panicking. That solves the problem but doesn't seem that desirable. Failing at runtime not ideal. OTOH, probably going to fail pretty fast if you are mixing different reactors. tmandry: Agreed that I would like to find some static way of talking about this. (Contexts and capabilities?) eholk: Or at least composable. --- ## async fn main tmandry > There could be a single built-in implementation of async fn main able to execute any content. Is this desirable from a performance/customization perspective? eholk: You could imagine having a crate that is the io-uring reactor, everyone ends up using that. tmandry: Not convinced we want to make everyone standardize on *one* reactor per tech. Maybe if it's a really thin layer. eholk: But if we have composable reactors we don't have to force you to pick one. tmandry: But how? eholk: Only way would be to spawn a thread. tmandry: I might be okay with a world where the first reactor runs on-thread, and other reactors spawn thread if they get used. eholk: Also curious about the fd-chaining mentioned in the footnote. eholk: Maybe the constraint is you need an OS that allows you to compose arbitrary blocking calls somehow. tmandry: You might have e.g. the epoll crate behave differently if the uring reactor is active on the same thread. Use an optional cargo dep and ask the crate if it's active, then set up fd-chaining or whatever, if that's more optimal than spawning a thread. eholk: Is there always a way to block? spawn a thread tmandry: But like in the thread-per-core case you need a Waker that's woken on the same thread, so you have to work that in. Probably just don't want to spawn a thread at all in that case. eholk: Spawning as a fallback can work. Seems bad for predictability. tmandry: In eholk: Could we do something in the type system? Like e.g. parameterize Future on what kind of blocking it can do. vincenzo: Useful for futures that expect to be singlethreaded too. --- vincenzo: Examples of needing multiple reactors? tmandry: * Interop, have TcpStream from two different kinds (uring, epoll) * UI Frameworks and event loops justin: Stacking glib on top of Qt on top of Mac event loop --- justin: Imagining some kind of "mega-reactor" that lets you compose reactors later. So there's some value in working this out now even without composability yet. --- (back to type parameter) justin: Status quo is e.g. futures will panic if the runtime isn't running. tmandry: Interested if we can express in the trait system that e.g. this reactor knows how to adapt to this other reactor. (Maybe some/all can fall back to spawning a thread) eholk: Can you express reactor constraints with contexts? tmandry: Yeah, something like ```rust impl Future for MyTcpStream with epoll_reactor::reactor_ctx { ... } ``` but I'm not sure how to work the adaptability part in. Actually, maybe it's like ```rust impl Future for MyTcpStream with std::async::reactor_ctx: CompatibleWithEpollReactor { ... } ``` eholk: ^ that's what I had in mind, I assume `reactor_ctx` has some requirement like `impl Reactor` but then you can add additional bounds where you need them. Then when you call the future it's up to you to set a context that impls all the necessary traits. tmandry: +1 :)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully