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 | ||
`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
Async reading club notes: Panics vs cancellation, part 1
https://smallcultfollowing.com/babysteps//blog/2022/01/27/panics-vs-cancellation-part-1/
tags:
reading-club
Why do panics not seem to cause so many problems but cancellation does?
await
, cannot recoverawait
is a potential cancellation point, but we don't communicate it as sucheholk: Cancellation seems like a more normal thing in the ecosystem than panic. Panic seems to happen almost purely in the erroneous case while cancellation seems to happen regularly as part of normal program execution.
nrc: norms and best practices for panic
e.g. thread boundaries, lock poisoning
panic feels well-understood.
tmandry: Whole point of poisoning is to keep your program from being in an inconsistent state. We don't do that for cancellation.
nrc But when you have to think about unwinding that's a more uncomfortable area (unsafe etc)
What did we get wrong with the ergonomics of lock poisoning, and how could we do better?
lock()
returns a result, when most people justunwrap
it..lock().unwrap()
?Did we fail to learn the lesson from this and
pthread_cancel
?Although…
Thread.stop:
https://aturon.github.io/tech/2016/09/07/futures-design/
source
Other languages have cancelation; difference between "forced cancelation" and "suggested cancelation".
Yosh: It is possible to
block_on
in a destructor with async_std. So you can ignore cancelation in this wayWhy is Java's Thread::stop bad: https://docs.oracle.com/javase/8/docs/technotes/guides/concurrency/threadPrimitiveDeprecation.html – doesn't the same reasoning apply to Rust?
If you drop a Future, the MutexGuard inside the future will just be dropped.
MutexGuard is not Send; if your task needs to be Send you can't hold it across await. But if your task doesn't need to be Send…
nrc: Java argument is that cancellation safety is too difficult so we'll make it illegal.
"Everything is in a consistent state at every await point" – yosh: I call this halt safety
yosh: Cancellation safety to me is "No side effects occur before you cancel at any await point", e.g. reading from a socket
Should we poison locks on cancellation? Probably. No way to tell whether it's a normal drop or not.
Tokio definition of cancellation safety: https://docs.rs/tokio/latest/tokio/macro.select.html#cancellation-safety