Skip to content

Commit

Permalink
Ch. 17: fix diagrams and embed them in the text
Browse files Browse the repository at this point in the history
- Swap the ordering to match the order in the text (concurrent is first,
  at least for now).
- Make them go left-to-right instead of top-to-bottom for compactness in
  the text.
- Fix rendering issues resulting from the VS Code extension doing things
  that normal `dot` does not, for who knows what reasons.
  • Loading branch information
chriskrycho committed Jul 26, 2024
1 parent cfaf187 commit 472f152
Show file tree
Hide file tree
Showing 6 changed files with 262 additions and 44 deletions.
45 changes: 34 additions & 11 deletions dot/trpl17-01.dot
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
digraph {
dpi = 300.0;

Parallel [label = "Parallel";shape = "plaintext";];
rankdir = "TB";
splines = false;
cluster = true;
rankdir = "LR";

// makes ordering between subgraphs work
newrank = true;

node [shape = diamond;];

subgraph cluster_ColleagueA {
newrank = true;
label = "Task 1";
A1 -> A2 -> A3 -> A4;
subgraph cluster_task_a {
label = "Task A";

A1;
A2;
A3;
A4;

A1 -> A2 -> A3 -> A4 -> A0 [style = invis;];

// for vertical alignment purposes only
A0 [style = invis;];

// Makes the heights line up between the boxes.
A4 -> A0 [style = invis;];
}

subgraph cluster_ColleagueB {
label = "Task 2";
B1 -> B2 -> B3;
subgraph cluster_task_b {
label = "Task B";

// for horizontal alignment purposes only
// newrank = true;

B0 [style = invis;];

B1;
B2;
B3;

B0 -> B1 -> B2 -> B3 [style = invis;];
}

A1 -> B1 -> A2 -> B2 -> A3 -> A4 -> B3;
}
40 changes: 7 additions & 33 deletions dot/trpl17-02.dot
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
digraph {
dpi = 300.0;

Concurrent [label = "Concurrent";shape = "plaintext";];
rankdir = "TB";
rankdir = "LR";
splines = false;
cluster = true;

node [shape = diamond;];

subgraph cluster_task_a {
label = "Task A";

// makes ordering between subgraphs work
subgraph cluster_ColleagueA {
newrank = true;

A1;
A2;
A3;
A4;

// for vertical alignment purposes only
A0 [style = invis;];

edge [style = invis;];
label = "Task 1";
A1 -> A2 -> A3 -> A4;
}

subgraph cluster_task_b {
label = "Task B";
cluster = true;

// for vertical alignment purposes only
newrank = true;

B0 [style = invis;];

B1;
B2;
B3;
subgraph cluster_ColleagueB {
label = "Task 2";
B1 -> B2 -> B3;
}

A1 -> B1 -> A2 -> B2 -> A3 -> A4 -> B3;

// Makes the heights line up between the boxes.
A4 -> A0 [style = invis;];
}
16 changes: 16 additions & 0 deletions src/ch17-00-async-await.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,26 @@ to the other. You are just one person, and you cannot make progress on both
tasks at the exact same time—but you can multi-task, making progress on multiple
tasks by switching between them.

<figure>

<img alt="Concurrent work flow" src="img/trpl17-01.svg" class="center" />

<figcaption>Figure 17-1: A concurrent workflow, switching between Task A and Task B</figcaption>

</figure>

When you agree to split up a group of tasks between the people on the team, with
each person taking one task and working on it alone, this is *parallelism*. Each
person on the team can make progress at the exact same time.

<figure>

<img alt="Concurrent work flow" src="img/trpl17-02.svg" class="center" />

<figcaption>Figure 17-2: A parallel workflow, where work happens on Task A and Task B independently</figcaption>

</figure>

With both of these situations, you might have to coordinate between different
tasks. Maybe you *thought* the task that one person was working on was totally
independent from everyone else’s work, but it actually needs something finished
Expand Down
1 change: 1 addition & 0 deletions src/img/trp17-02.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 110 additions & 0 deletions src/img/trpl17-01.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions src/img/trpl17-02.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 472f152

Please sign in to comment.