or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~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; ``` |
|
||
:smile: | Emoji list | ||
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
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.
Syncing
xxxxxxxxxx
ReadingWatching notes: Trio: Async concurrency for mere mortalsLink to document: https://www.youtube.com/watch?v=oLkfnc_UMcE
tags:
reading-club
Leave questions, observations, discussion topics below.
Topic
name: prompt
Does trio expose more concurrency operators now?
Happy eye-balls seems to implement "try race" / "race ok" semantics, implemented by for example
futures_concurrency::future::RaceOk
in Rust or in JSPromise.any
. Thetrio
talk is from 2018, has trio gained more vocabulary to express concurrency control flow?Nathaniel: It turns out that you can write anything with this, so we stick with that and let other people write utilities on top if they want.
This makes it possible to say "I'm going to teach you all of concurrency in 20 minutes"! A good way to design an API is to start by going to write the docs for it.
Simple implementation of happy eyeballs in a talk is a success
Rust is struggling with this… "first we have to tell you about Pin!"
Nathaniel's ideas and suggestions on async Rust
Impressed by the current state of async Rust; has advantages over other approaches.
Can go really far with this approach until you hit problems, but then maybe you have "more to unwind".
Rust took kind of a hill-climbing approach (maybe the only approach)… started with Futures, which was a nice model but not good enough, but then we add more features and complexity to the language itself to accommodate.
A lot of complexity comes from directly exposing future objects to the user.
Trio/Python uses a very similar model actually.. an async function returns a coroutine object, Python has Awaitable objects… but we don't mention it at all because we can get away with that. (Except magic
trio.run()
at the top)Can't change async/await but
Strawman proposal
Fiber functions - don't have to use
await
, you don't get to see future objectsawait
and it's an error not toNeed to be able to pass one of these to the nursery start function. Adapter that takes one of them and implements the
Future
trait.Yosh: Is it accurate to say that Trio async functions start eagerly?
njs: In Python, if you want to make things that don't start eagerly you make a data structure that contains callables
https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async/topic/undroppable.20async.20fns
"Cancellation should be ambient (no special token) and delimited", described in a blog post – https://vorpus.org/blog/timeouts-and-cancellation-for-humans/
With an exception-based approach it can be unclear when you should stop propagating the cancellation. If you call
cancel
on a task which triggers an exception, how do you know where to stop propagating the exception? both cancel scopes (trio) and drop-based cancellation (rust) have this property