some minor changes

This commit is contained in:
cfsamson
2020-02-05 16:45:03 +01:00
parent 6dd174c9e1
commit 4c51fba01a
3 changed files with 12 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ This naming scheme is Rust deliberately testing if you're too tired to safely im
`!Unpin` it's a good sign that it's time to lay down the work and start over `!Unpin` it's a good sign that it's time to lay down the work and start over
tomorrow with a fresh mind. tomorrow with a fresh mind.
> That was of course a joke. There are very valid reasons for the names > I hope you didn't mind the joke. There are valid reasons for the names
> that were chosen. If you want you can read a bit of the discussion from the > that were chosen. If you want you can read a bit of the discussion from the
> [internals thread][internals_unpin]. The best takeaway from there in my eyes > [internals thread][internals_unpin]. The best takeaway from there in my eyes
> is this quote from `tmandry`: > is this quote from `tmandry`:

View File

@@ -569,7 +569,7 @@ fn main() {
# let handle = thread::spawn(move || { # let handle = thread::spawn(move || {
# // This simulates some I/O resource # // This simulates some I/O resource
# for event in rx { # for event in rx {
# println!("GOT EVENT: {:?}", event); # println!("REACTOR: {:?}", event);
# let rl_clone = rl_clone.clone(); # let rl_clone = rl_clone.clone();
# match event { # match event {
# Event::Close => break, # Event::Close => break,
@@ -622,6 +622,14 @@ fn main() {
# } # }
``` ```
I added a debug printout of the events the reactor registered interest for so we can observe
two things:
1. How the `Waker` object looks just like the _trait object_ we talked about in an earlier chapter
2. In what order the events register interest with the reactor
The last point is relevant when we move on the the last paragraph.
## Async/Await and concurrent Futures ## Async/Await and concurrent Futures
This is the first time we actually see the `async/await` syntax so let's This is the first time we actually see the `async/await` syntax so let's
@@ -844,7 +852,7 @@ fn main() {
# let handle = thread::spawn(move || { # let handle = thread::spawn(move || {
# // This simulates some I/O resource # // This simulates some I/O resource
# for event in rx { # for event in rx {
# println!("GOT EVENT: {:?}", event); # println!("REACTOR: {:?}", event);
# let rl_clone = rl_clone.clone(); # let rl_clone = rl_clone.clone();
# match event { # match event {
# Event::Close => break, # Event::Close => break,

View File

@@ -154,7 +154,7 @@ impl Reactor {
let handle = thread::spawn(move || { let handle = thread::spawn(move || {
// This simulates some I/O resource // This simulates some I/O resource
for event in rx { for event in rx {
println!("GOT EVENT: {:?}", event); println!("REACTOR: {:?}", event);
let rl_clone = rl_clone.clone(); let rl_clone = rl_clone.clone();
match event { match event {
Event::Close => break, Event::Close => break,