Skip to content

Commit e2ce4c0

Browse files
committed
added readmes, spelling, minor fixes
1 parent a727f44 commit e2ce4c0

File tree

17 files changed

+94
-64
lines changed

17 files changed

+94
-64
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
target/
2-
Cargo.lock
2+
Cargo.lock
3+
.vscode

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Asynchronous Programming in Rust
22

3-
This is the repository for the book: Asynchronous Programming in Rust - learn asynchronous programming from first principles.
3+
This is the repository for the book: _Asynchronous Programming in Rust_.
44

55
Written by Carl Fredrik Samson, published by Packt
66

@@ -12,9 +12,9 @@ Each chapter has its own folder in this repository. Each example is organized as
1212

1313
When encountering examples in the book, you might find it easier to read the code in the repository since you'll be able to open it up in the editor of your choice and have appropriate highlighting and formatting.
1414

15-
Even if you prefer to write the examples from the book line by line, you'll need the repository for `delayserver` and `corofy` which is two tools I wrote to help in the learning process.
15+
Even if you only write the examples directly from the book line by line, you'll need the repository for `delayserver` and `corofy` which is two tools I wrote to help in the learning process.
1616

17-
## I'll be going on a plane, how can I use the repository in an offline situation?
17+
## I'm going on a plane, how can I use the repository in an offline situation?
1818

1919
You'll need to install both `delayserver` and `corofy` locally on your machine while you're online. The process is described below.
2020

@@ -28,10 +28,12 @@ Most of the examples will use a program called delayserver that's provided in th
2828
You have two options for running the delayserver:
2929

3030
1. Go to the folder named `/delayserver` and write `cargo run` in a separate terminal window and leave it running there
31-
2. Go to the delayserver and install the server by writing `cargo install --force --path .`. By doing so you install the program locally in you PATH so you can run it from any location by simply writing `delayserver` and leave the terminal process running.
31+
2. Go to the same folder and install the server by writing `cargo install --force --path .`. By doing so you install the program locally in you PATH so you can run it from any location by simply writing `delayserver` and leave the terminal process running.
32+
33+
How delayserver works is described in the book, but you'll also find the relavant information in its root folder.
3234

3335
## Corofy
3436

35-
Corofy is another tool that we'll use from chapter 7 onwards. I recommend installing this tool by entering the folder `ch7/corofy` and installing it on your machine by writing `cargo install --force --path .`
37+
Corofy is another tool that we'll use from chapter 7 onwards. I recommend installing this tool locally by entering the folder `ch7/corofy` and installing it on your machine by writing `cargo install --force --path .`
3638

3739
Asynchronous Programming in Rust, published by Packt

ch01/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Chapter 1 - Concurrency and Asynchronous Programming: A Detailed Overview
2+
3+
This folder contains the code examples for Chapter 1.

ch02/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Chapter 2 - How Programming Languages Model Asynchronous Program Flow
2+
3+
This folder contains the code examples for Chapter 2.

ch03/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Chapter 3 - Understanding OS-backed Event Queues, System Calls and Cross Platform Abstractions
2+
3+
This folder contains the code examples for Chapter 3.

ch04/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Chapter 4 - Create Your Own Event Queue
2+
3+
This folder contains the code examples for Chapter 4.

ch05/How-to-MacOS-M.md

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# How to run these examples on a Mac with an M-series chip
1+
# How to run these examples on a Mac with an M-seriXes chip
22

33
Newer Macs use a chip using the ARM ISA, which won't work out of the box with
44
these examples. However, these Macs ship with an emulation software called Rosetta
@@ -16,33 +16,21 @@ It should report `i386`.
1616
3. Run `rustup target add x86_64-apple-darwin`
1717
4. You can now run the examples using the command: `cargo run --target x86_64-apple-darwin`
1818

19-
## Important
19+
## Note
2020

2121
In the example: "c-fibers" and "d-fibers-closure" (and "e-fibers-windows"
22-
since it works on both platforms), you'll notice that we set a slightly
23-
different name when the function is exported on MacOS and even though we
24-
write `#[no_mangle]`, the compiler prepends the name of the function with an
25-
underscore `_`.
22+
since it works on both platforms), you'll notice that we use a conditional
23+
compilation attribute for `macos` targets.
2624

2725
This is due to the platform ABI on MacOS which expects functions to be prepended
28-
with `_`. So, when we call the function in our inline assembly later on
29-
we need to account for that. For example by changing:
26+
with `_`. So, LLVM will by default add an underscore to our functions even if we
27+
tag them with `#[no_mangle]`.
3028

31-
```rust
32-
asm!("call switch", in("rdi") old, in("rsi") new, clobber_abi("C"));
33-
```
34-
35-
To:
36-
37-
```rust
38-
asm!("call _switch", in("rdi") old, in("rsi") new, clobber_abi("C"));
39-
```
40-
41-
Another workaround is to strip the first byte of the name on
42-
export by adding the attribute below to the `switch` function:
29+
The workaround we use is to strip the first byte of the name that's exported
30+
by LLVM on MacOS by adding the attribute below to the `switch` function:
4331

4432
```rust
4533
#[cfg_attr(target_os = "macos", export_name = "\x01switch")]
4634
```
4735

48-
You can read more about this here: https://github.com/rust-lang/rust/issues/35052#issuecomment-235420755
36+
You can read more about this here: <https://github.com/rust-lang/rust/issues/35052#issuecomment-235420755>

ch05/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Chapter 5 - Creating Our Own Fibers
2+
3+
This folder contains the code examples for Chapter 5.
4+
5+
## Note
6+
7+
For MacOS users running M-family chips (most newer Macs), there is a few
8+
simple steps you can take to get the example running on your machine.
9+
10+
It's explained step-by-step in [How-to-MacOS-M.md](./How-to-MacOS-M.md).

ch08/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Chapter 7 - Coroutines and async/await
2+
3+
This folder contains the code examples for Chapter 7.
4+
5+
## Note
6+
7+
This folder also contains `corofy` that you'll need to install locally since
8+
you need it in this and the following chapters.
9+
10+
You'll find all the details on how to do this both in the book and in the [corofy](./corofy/) folder.

0 commit comments

Comments
 (0)