mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 10:24:33 -06:00
Ch. 17: fix diagrams and embed them in the text
- 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.
This commit is contained in:
+34
-11
@@ -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;
|
||||
}
|
||||
+7
-33
@@ -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;];
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg height="1320pt" viewBox="0 0 253.38 316.8" width="1056pt" xmlns="http://www.w3.org/2000/svg"><g transform="matrix(.45153033 0 0 .45153033 56.962413 243.406039)"><path d="m-4 4v-316.8h253.38v316.8z" fill="#fff"/><path d="m69.38-8v-292.8h80v292.8z" fill="none" stroke="#000"/><text font-family="Times,serif" font-size="14" text-anchor="middle" x="109.38" y="-284.2">Task 1</text><path d="m157.38-80v-220.8h80v220.8z" fill="none" stroke="#000"/><text font-family="Times,serif" font-size="14" text-anchor="middle" x="197.38" y="-284.2">Task 2</text><g pointer-events="visible"><text font-family="Times,serif" font-size="14" text-anchor="middle" x="29.38" y="-245.8">Parallel</text><g><path d="m109.38-268-32.1 18 32.1 18 32.1-18z" fill="none" stroke="#000"/><text font-family="Times,serif" font-size="14" text-anchor="middle" x="109.38" y="-245.8">A1</text></g><g><path d="m109.38-196-32.1 18 32.1 18 32.1-18z" fill="none" stroke="#000"/><text font-family="Times,serif" font-size="14" text-anchor="middle" x="109.38" y="-173.8">A2</text></g></g><path d="m109.38-231.7v24.16" fill="none" stroke="#000"/><path d="m112.88-207.62-3.5 10-3.5-10z" stroke="#000"/><g pointer-events="visible"><path d="m109.38-124-32.1 18 32.1 18 32.1-18z" fill="none" stroke="#000"/><text font-family="Times,serif" font-size="14" text-anchor="middle" x="109.38" y="-101.8">A3</text></g><path d="m109.38-159.7v24.16" fill="none" stroke="#000"/><path d="m112.88-135.62-3.5 10-3.5-10z" stroke="#000"/><g pointer-events="visible"><path d="m109.38-52-32.1 18 32.1 18 32.1-18z" fill="none" stroke="#000"/><text font-family="Times,serif" font-size="14" text-anchor="middle" x="109.38" y="-29.8">A4</text></g><path d="m109.38-87.7v24.16" fill="none" stroke="#000"/><path d="m112.88-63.62-3.5 10-3.5-10z" stroke="#000"/><g pointer-events="visible"><path d="m197.38-268-31.59 18 31.59 18 31.59-18z" fill="none" stroke="#000"/><text font-family="Times,serif" font-size="14" text-anchor="middle" x="197.38" y="-245.8">B1</text></g><g pointer-events="visible"><path d="m197.38-196-31.59 18 31.59 18 31.59-18z" fill="none" stroke="#000"/><text font-family="Times,serif" font-size="14" text-anchor="middle" x="197.38" y="-173.8">B2</text></g><path d="m197.38-231.7v24.16" fill="none" stroke="#000"/><path d="m200.88-207.62-3.5 10-3.5-10z" stroke="#000"/><g pointer-events="visible"><path d="m197.38-124-31.59 18 31.59 18 31.59-18z" fill="none" stroke="#000"/><text font-family="Times,serif" font-size="14" text-anchor="middle" x="197.38" y="-101.8">B3</text></g><path d="m197.38-159.7v24.16" fill="none" stroke="#000"/><path d="m200.88-135.62-3.5 10-3.5-10z" stroke="#000"/></g></svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.0.0 (20240704.0754)
|
||||
-->
|
||||
<!-- Pages: 1 -->
|
||||
<svg height="640pt"
|
||||
viewBox="0.00 0.00 2884 775" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(4.16667 4.16667) rotate(0) translate(4 182)">
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-182 688.21,-182 688.21,4 -4,4"/>
|
||||
<g id="clust1" class="cluster">
|
||||
<title>cluster_task_a</title>
|
||||
<polygon fill="none" stroke="black" points="8,-93 8,-170 676.21,-170 676.21,-93 8,-93"/>
|
||||
<text text-anchor="middle" x="342.11" y="-152.7" font-family="Times,serif" font-size="14.00">Task A</text>
|
||||
</g>
|
||||
<g id="clust2" class="cluster">
|
||||
<title>cluster_task_b</title>
|
||||
<polygon fill="none" stroke="black" points="8.72,-8 8.72,-85 675.49,-85 675.49,-8 8.72,-8"/>
|
||||
<text text-anchor="middle" x="342.11" y="-67.7" font-family="Times,serif" font-size="14.00">Task B</text>
|
||||
</g>
|
||||
<!-- A1 -->
|
||||
<g id="node1" class="node">
|
||||
<title>A1</title>
|
||||
<polygon fill="none" stroke="black" points="47.36,-137 16,-119 47.36,-101 78.73,-119 47.36,-137"/>
|
||||
<text text-anchor="middle" x="47.36" y="-113.95" font-family="Times,serif" font-size="14.00">A1</text>
|
||||
</g>
|
||||
<!-- A2 -->
|
||||
<g id="node2" class="node">
|
||||
<title>A2</title>
|
||||
<polygon fill="none" stroke="black" points="243.38,-137 212.01,-119 243.38,-101 274.74,-119 243.38,-137"/>
|
||||
<text text-anchor="middle" x="243.38" y="-113.95" font-family="Times,serif" font-size="14.00">A2</text>
|
||||
</g>
|
||||
<!-- A1->A2 -->
|
||||
<!-- B1 -->
|
||||
<g id="node7" class="node">
|
||||
<title>B1</title>
|
||||
<polygon fill="none" stroke="black" points="145.37,-52 114.73,-34 145.37,-16 176.01,-34 145.37,-52"/>
|
||||
<text text-anchor="middle" x="145.37" y="-28.95" font-family="Times,serif" font-size="14.00">B1</text>
|
||||
</g>
|
||||
<!-- A1->B1 -->
|
||||
<g id="edge9" class="edge">
|
||||
<title>A1->B1</title>
|
||||
<path fill="none" stroke="black" d="M60.52,-108.23C76.47,-94.12 104.66,-69.16 123.92,-52.11"/>
|
||||
<polygon fill="black" stroke="black" points="126.01,-54.93 131.18,-45.68 121.37,-49.69 126.01,-54.93"/>
|
||||
</g>
|
||||
<!-- A3 -->
|
||||
<g id="node3" class="node">
|
||||
<title>A3</title>
|
||||
<polygon fill="none" stroke="black" points="439.39,-137 408.02,-119 439.39,-101 470.75,-119 439.39,-137"/>
|
||||
<text text-anchor="middle" x="439.39" y="-113.95" font-family="Times,serif" font-size="14.00">A3</text>
|
||||
</g>
|
||||
<!-- A2->A3 -->
|
||||
<!-- B2 -->
|
||||
<g id="node8" class="node">
|
||||
<title>B2</title>
|
||||
<polygon fill="none" stroke="black" points="341.38,-52 310.74,-34 341.38,-16 372.02,-34 341.38,-52"/>
|
||||
<text text-anchor="middle" x="341.38" y="-28.95" font-family="Times,serif" font-size="14.00">B2</text>
|
||||
</g>
|
||||
<!-- A2->B2 -->
|
||||
<g id="edge11" class="edge">
|
||||
<title>A2->B2</title>
|
||||
<path fill="none" stroke="black" d="M256.54,-108.23C272.48,-94.12 300.68,-69.16 319.93,-52.11"/>
|
||||
<polygon fill="black" stroke="black" points="322.02,-54.93 327.19,-45.68 317.38,-49.69 322.02,-54.93"/>
|
||||
</g>
|
||||
<!-- A4 -->
|
||||
<g id="node4" class="node">
|
||||
<title>A4</title>
|
||||
<polygon fill="none" stroke="black" points="538.12,-137 506.75,-119 538.12,-101 569.48,-119 538.12,-137"/>
|
||||
<text text-anchor="middle" x="538.12" y="-113.95" font-family="Times,serif" font-size="14.00">A4</text>
|
||||
</g>
|
||||
<!-- A3->A4 -->
|
||||
<!-- A3->A4 -->
|
||||
<g id="edge13" class="edge">
|
||||
<title>A3->A4</title>
|
||||
<path fill="none" stroke="black" d="M461.38,-124.68C473.97,-125.79 490.25,-126.04 504.48,-125.42"/>
|
||||
<polygon fill="black" stroke="black" points="504.57,-128.92 514.33,-124.8 504.13,-121.94 504.57,-128.92"/>
|
||||
</g>
|
||||
<!-- A0 -->
|
||||
<!-- A4->A0 -->
|
||||
<!-- A4->A0 -->
|
||||
<!-- B3 -->
|
||||
<g id="node9" class="node">
|
||||
<title>B3</title>
|
||||
<polygon fill="none" stroke="black" points="636.85,-52 606.21,-34 636.85,-16 667.49,-34 636.85,-52"/>
|
||||
<text text-anchor="middle" x="636.85" y="-28.95" font-family="Times,serif" font-size="14.00">B3</text>
|
||||
</g>
|
||||
<!-- A4->B3 -->
|
||||
<g id="edge14" class="edge">
|
||||
<title>A4->B3</title>
|
||||
<path fill="none" stroke="black" d="M551.37,-108.23C567.43,-94.12 595.84,-69.16 615.24,-52.11"/>
|
||||
<polygon fill="black" stroke="black" points="617.36,-54.91 622.56,-45.68 612.74,-49.65 617.36,-54.91"/>
|
||||
</g>
|
||||
<!-- B0 -->
|
||||
<!-- B0->B1 -->
|
||||
<!-- B1->A2 -->
|
||||
<g id="edge10" class="edge">
|
||||
<title>B1->A2</title>
|
||||
<path fill="none" stroke="black" d="M158.53,-44.77C174.47,-58.88 202.67,-83.84 221.93,-100.89"/>
|
||||
<polygon fill="black" stroke="black" points="219.38,-103.31 229.18,-107.32 224.02,-98.07 219.38,-103.31"/>
|
||||
</g>
|
||||
<!-- B1->B2 -->
|
||||
<!-- B2->A3 -->
|
||||
<g id="edge12" class="edge">
|
||||
<title>B2->A3</title>
|
||||
<path fill="none" stroke="black" d="M354.54,-44.77C370.48,-58.88 398.68,-83.84 417.94,-100.89"/>
|
||||
<polygon fill="black" stroke="black" points="415.39,-103.31 425.2,-107.32 420.03,-98.07 415.39,-103.31"/>
|
||||
</g>
|
||||
<!-- B2->B3 -->
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.0.0 (20240704.0754)
|
||||
-->
|
||||
<!-- Pages: 1 -->
|
||||
<svg height="640pt"
|
||||
viewBox="0.00 0.00 1662 775" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(4.16667 4.16667) rotate(0) translate(4 182)">
|
||||
<polygon fill="white" stroke="none" points="-4,4 -4,-182 394.92,-182 394.92,4 -4,4"/>
|
||||
<g id="clust1" class="cluster">
|
||||
<title>cluster_ColleagueA</title>
|
||||
<polygon fill="none" stroke="black" points="8,-8 8,-85 382.92,-85 382.92,-8 8,-8"/>
|
||||
<text text-anchor="middle" x="195.46" y="-67.7" font-family="Times,serif" font-size="14.00">Task 1</text>
|
||||
</g>
|
||||
<g id="clust2" class="cluster">
|
||||
<title>cluster_ColleagueB</title>
|
||||
<polygon fill="none" stroke="black" points="8.72,-93 8.72,-170 283.47,-170 283.47,-93 8.72,-93"/>
|
||||
<text text-anchor="middle" x="146.09" y="-152.7" font-family="Times,serif" font-size="14.00">Task 2</text>
|
||||
</g>
|
||||
<!-- A1 -->
|
||||
<g id="node1" class="node">
|
||||
<title>A1</title>
|
||||
<polygon fill="none" stroke="black" points="47.36,-52 16,-34 47.36,-16 78.73,-34 47.36,-52"/>
|
||||
<text text-anchor="middle" x="47.36" y="-28.95" font-family="Times,serif" font-size="14.00">A1</text>
|
||||
</g>
|
||||
<!-- A2 -->
|
||||
<g id="node2" class="node">
|
||||
<title>A2</title>
|
||||
<polygon fill="none" stroke="black" points="146.09,-52 114.73,-34 146.09,-16 177.46,-34 146.09,-52"/>
|
||||
<text text-anchor="middle" x="146.09" y="-28.95" font-family="Times,serif" font-size="14.00">A2</text>
|
||||
</g>
|
||||
<!-- A1->A2 -->
|
||||
<g id="edge1" class="edge">
|
||||
<title>A1->A2</title>
|
||||
<path fill="none" stroke="black" d="M79.5,-34C86.84,-34 94.78,-34 102.52,-34"/>
|
||||
<polygon fill="black" stroke="black" points="102.5,-37.5 112.5,-34 102.5,-30.5 102.5,-37.5"/>
|
||||
</g>
|
||||
<!-- A3 -->
|
||||
<g id="node3" class="node">
|
||||
<title>A3</title>
|
||||
<polygon fill="none" stroke="black" points="244.82,-52 213.46,-34 244.82,-16 276.19,-34 244.82,-52"/>
|
||||
<text text-anchor="middle" x="244.82" y="-28.95" font-family="Times,serif" font-size="14.00">A3</text>
|
||||
</g>
|
||||
<!-- A2->A3 -->
|
||||
<g id="edge2" class="edge">
|
||||
<title>A2->A3</title>
|
||||
<path fill="none" stroke="black" d="M178.23,-34C185.57,-34 193.51,-34 201.25,-34"/>
|
||||
<polygon fill="black" stroke="black" points="201.23,-37.5 211.23,-34 201.23,-30.5 201.23,-37.5"/>
|
||||
</g>
|
||||
<!-- A4 -->
|
||||
<g id="node4" class="node">
|
||||
<title>A4</title>
|
||||
<polygon fill="none" stroke="black" points="343.55,-52 312.19,-34 343.55,-16 374.92,-34 343.55,-52"/>
|
||||
<text text-anchor="middle" x="343.55" y="-28.95" font-family="Times,serif" font-size="14.00">A4</text>
|
||||
</g>
|
||||
<!-- A3->A4 -->
|
||||
<g id="edge3" class="edge">
|
||||
<title>A3->A4</title>
|
||||
<path fill="none" stroke="black" d="M276.96,-34C284.3,-34 292.24,-34 299.98,-34"/>
|
||||
<polygon fill="black" stroke="black" points="299.96,-37.5 309.96,-34 299.96,-30.5 299.96,-37.5"/>
|
||||
</g>
|
||||
<!-- B1 -->
|
||||
<g id="node5" class="node">
|
||||
<title>B1</title>
|
||||
<polygon fill="none" stroke="black" points="47.36,-137 16.72,-119 47.36,-101 78.01,-119 47.36,-137"/>
|
||||
<text text-anchor="middle" x="47.36" y="-113.95" font-family="Times,serif" font-size="14.00">B1</text>
|
||||
</g>
|
||||
<!-- B2 -->
|
||||
<g id="node6" class="node">
|
||||
<title>B2</title>
|
||||
<polygon fill="none" stroke="black" points="146.09,-137 115.45,-119 146.09,-101 176.74,-119 146.09,-137"/>
|
||||
<text text-anchor="middle" x="146.09" y="-113.95" font-family="Times,serif" font-size="14.00">B2</text>
|
||||
</g>
|
||||
<!-- B1->B2 -->
|
||||
<g id="edge4" class="edge">
|
||||
<title>B1->B2</title>
|
||||
<path fill="none" stroke="black" d="M78.97,-119C86.72,-119 95.18,-119 103.37,-119"/>
|
||||
<polygon fill="black" stroke="black" points="103.17,-122.5 113.17,-119 103.17,-115.5 103.17,-122.5"/>
|
||||
</g>
|
||||
<!-- B3 -->
|
||||
<g id="node7" class="node">
|
||||
<title>B3</title>
|
||||
<polygon fill="none" stroke="black" points="244.82,-137 214.18,-119 244.82,-101 275.47,-119 244.82,-137"/>
|
||||
<text text-anchor="middle" x="244.82" y="-113.95" font-family="Times,serif" font-size="14.00">B3</text>
|
||||
</g>
|
||||
<!-- B2->B3 -->
|
||||
<g id="edge5" class="edge">
|
||||
<title>B2->B3</title>
|
||||
<path fill="none" stroke="black" d="M177.7,-119C185.45,-119 193.91,-119 202.1,-119"/>
|
||||
<polygon fill="black" stroke="black" points="201.9,-122.5 211.9,-119 201.9,-115.5 201.9,-122.5"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.2 KiB |
Reference in New Issue
Block a user