Files
2026-10-16 09:05:43 +02:00

188 lines
10 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 560 730" width="560" height="730"
role="img" aria-labelledby="mj-title">
<title id="mj-title">The mediated version inside one JVM: ConsoleIn puts a message into consoleIn.outbox, a mediator takes it and puts it into rot13.inbox, ROT13 takes it and puts its result into rot13.outbox, a second mediator moves that into consoleOut.inbox, and ConsoleOut takes it and prints it.</title>
<style><![CDATA[
/* figures/diagram.css -- shared look of every built figure.
*
* build-figures.py drops this file into the style element of every built
* svg, so a figure carries its own styling and stays self-contained.
* Classes, not per-element fills, do the work: one edit here restyles the
* whole book.
*
* Colours are the extension's tokens (_extensions/notes/theme.css) with a
* literal fallback, which covers all three ways a figure is seen:
*
* - inlined into the page by figures/flow-player.html: the tokens resolve
* against the page, so the figure follows light, night and high contrast;
* - as a plain <img> (JavaScript off): the fallback applies, and night mode
* comes from the extension's invert filter on main img[src$=".svg"];
* - in the pdf: librsvg ignores var() and uses the fallback, so print gets
* the light palette -- which is what a printed page wants.
*
* The fallbacks are this book's own light values; the tokens carry the night
* and high-contrast ones. Nothing here keys off prefers-color-scheme: the
* page's toggle decides, never the reader's system setting.
*/
svg {
font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
/* the figure sits on the page, not on a white card of its own */
background: transparent;
}
/* ---- surfaces ------------------------------------------------------- */
.box { fill: var(--calc-faint, #eef3f7); stroke: var(--calc-notecolor, #20666f); stroke-width: 1.4; }
.box-weak { fill: var(--calc-faint, #eef3f7); stroke: var(--calc-notecolor, #20666f); stroke-width: 1.4; }
.box-accent { fill: var(--calc-faint, #e5eff1); stroke: var(--calc-notecolor, #20666f); stroke-width: 1.8; }
.box-warn { fill: var(--calc-faint, #f8f1e0); stroke: var(--calc-accent-b, #D1541F); stroke-width: 1.4; }
.box-plain { fill: var(--calc-surface, #fbfcfd); stroke: var(--calc-grid, #dae0e8); stroke-width: 1.2; }
.diamond { fill: var(--calc-faint, #e5eff1); stroke: var(--calc-notecolor, #20666f); stroke-width: 1.4; }
.ellipse { fill: var(--calc-surface, #fbfcfd); stroke: var(--calc-muted, #5a6879); stroke-width: 1.2; }
/* ---- lines ---------------------------------------------------------- */
.edge { fill: none; stroke: var(--calc-muted, #5a6879); stroke-width: 1.3; }
.edge-strong{ fill: none; stroke: var(--calc-notecolor, #20666f); stroke-width: 1.8; }
.edge-warn { fill: none; stroke: var(--calc-accent-b, #D1541F); stroke-width: 1.6; }
.edge-dash { fill: none; stroke: var(--calc-muted, #5a6879); stroke-width: 1.2; stroke-dasharray: 5 3; }
.rule { stroke: var(--calc-grid, #dae0e8); stroke-width: 1; }
/* ---- text ----------------------------------------------------------- */
.t { fill: var(--calc-ink, #1b2430); font-size: 13px; }
.t-sm { fill: var(--calc-ink, #1b2430); font-size: 11px; }
.t-lead { fill: var(--calc-ink, #1b2430); font-size: 14px; font-weight: 600; }
.t-mut { fill: var(--calc-muted, #5a6879); font-size: 11px; }
.t-key { fill: var(--calc-ink, #1b2430); font-size: 12px; text-decoration: underline; }
.t-accent { fill: var(--calc-notecolor, #20666f); font-size: 12px; font-weight: 600; }
.t-warn { fill: var(--calc-accent-b, #D1541F); font-size: 12px; font-weight: 600; }
.t-mono { fill: var(--calc-ink, #1b2430); font-size: 11.5px;
font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace; }
.mid { text-anchor: middle; }
.end { text-anchor: end; }
/* ---- interaction ====================================================
* A .node groups one box with its labels. Hovering it lifts the whole group
* a little, which is enough to follow a path through a busy diagram without
* any script. Pointer events stay off the decorative layers so the hover
* target is the shape itself.
*/
.node { transition: opacity .12s ease; }
.node:hover .box,
.node:hover .box-accent,
.node:hover .diamond { stroke-width: 2.6; }
.node:hover .t, .node:hover .t-lead { fill: var(--calc-notecolor, #20666f); }
svg:hover .node:not(:hover) { opacity: .55; }
/* a figure that marks no nodes must not dim on hover */
svg:not(:has(.node)) .node { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
.node { transition: none; }
}
/* ---- arrowheads ======================================================
* marker contents cannot inherit the referencing element's fill, so each
* arrowhead is its own class and is themed alongside the line it ends.
*/
.arrow { fill: var(--calc-muted, #5a6879); }
.arrow-strong { fill: var(--calc-notecolor, #20666f); }
.arrow-warn { fill: var(--calc-accent-b, #D1541F); }
]]></style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5"
markerWidth="6.5" markerHeight="6.5" orient="auto-start-reverse">
<path class="arrow" d="M0,0 L10,5 L0,10 z"/>
</marker>
</defs>
<!-- one JVM, five virtual threads: the frame the whole chain lives in -->
<rect class="box-plain" x="10" y="10" width="540" height="676" rx="4"/>
<text class="t-mut" data-label="frame" x="22" y="30">one JVM · five virtual threads · BlockingQueue mailboxes</text>
<!-- 1. ConsoleIn ==================================================== -->
<g class="node" data-flow-node="consolein">
<rect class="box" x="120" y="44" width="300" height="44" rx="3"/>
<text class="t-lead mid" data-label="consolein" x="270" y="72">ConsoleIn — “I read”</text>
</g>
<path class="edge" data-flow="1" data-flow-to="outbox1" d="M270,88 V114" marker-end="url(#a)"/>
<text class="t-accent" data-label="put1" x="286" y="106">put</text>
<!-- 2. consoleIn.outbox ============================================= -->
<g class="node" data-flow-node="outbox1">
<rect class="box-plain" x="120" y="116" width="300" height="44" rx="3"/>
<text class="t-mono mid" x="270" y="144">consoleIn.outbox</text>
</g>
<path class="edge" data-flow="2" data-flow-to="mediator1" d="M270,160 V186" marker-end="url(#a)"/>
<text class="t-accent" data-label="take1" x="286" y="178">take</text>
<!-- 3. first mediator =============================================== -->
<g class="node" data-flow-node="mediator1">
<rect class="box-accent" x="120" y="188" width="300" height="44" rx="3"/>
<text class="t-lead mid" data-label="mediator1" x="270" y="211">Mediator</text>
<text class="t-mut mid" data-label="route1" x="270" y="226">consoleIn.outbox → rot13.inbox</text>
</g>
<path class="edge" data-flow="3" data-flow-to="inbox2" d="M270,232 V258" marker-end="url(#a)"/>
<text class="t-accent" data-label="put2" x="286" y="250">put</text>
<!-- 4. rot13.inbox =================================================== -->
<g class="node" data-flow-node="inbox2">
<rect class="box-plain" x="120" y="260" width="300" height="44" rx="3"/>
<text class="t-mono mid" x="270" y="288">rot13.inbox</text>
</g>
<path class="edge" data-flow="4" data-flow-to="rot13" d="M270,304 V330" marker-end="url(#a)"/>
<text class="t-accent" data-label="take2" x="286" y="322">take</text>
<!-- 5. ROT13 ========================================================= -->
<g class="node" data-flow-node="rot13">
<rect class="box" x="120" y="332" width="300" height="44" rx="3"/>
<text class="t-lead mid" data-label="rot13" x="270" y="360">ROT13 — “I rotate”</text>
</g>
<path class="edge" data-flow="5" data-flow-to="outbox2" d="M270,376 V402" marker-end="url(#a)"/>
<text class="t-accent" data-label="put3" x="286" y="394">put</text>
<!-- 6. rot13.outbox ================================================== -->
<g class="node" data-flow-node="outbox2">
<rect class="box-plain" x="120" y="404" width="300" height="44" rx="3"/>
<text class="t-mono mid" x="270" y="432">rot13.outbox</text>
</g>
<path class="edge" data-flow="6" data-flow-to="mediator2" d="M270,448 V474" marker-end="url(#a)"/>
<text class="t-accent" data-label="take3" x="286" y="466">take</text>
<!-- 7. second mediator =============================================== -->
<g class="node" data-flow-node="mediator2">
<rect class="box-accent" x="120" y="476" width="300" height="44" rx="3"/>
<text class="t-lead mid" data-label="mediator2" x="270" y="499">Mediator</text>
<text class="t-mut mid" data-label="route2" x="270" y="514">rot13.outbox → consoleOut.inbox</text>
</g>
<path class="edge" data-flow="7" data-flow-to="inbox3" d="M270,520 V546" marker-end="url(#a)"/>
<text class="t-accent" data-label="put4" x="286" y="538">put</text>
<!-- 8. consoleOut.inbox ============================================== -->
<g class="node" data-flow-node="inbox3">
<rect class="box-plain" x="120" y="548" width="300" height="44" rx="3"/>
<text class="t-mono mid" x="270" y="576">consoleOut.inbox</text>
</g>
<path class="edge" data-flow="8" data-flow-to="consoleout" d="M270,592 V618" marker-end="url(#a)"/>
<text class="t-accent" data-label="take4" x="286" y="610">take</text>
<!-- 9. ConsoleOut ==================================================== -->
<g class="node" data-flow-node="consoleout">
<rect class="box" x="120" y="620" width="300" height="44" rx="3"/>
<text class="t-lead mid" data-label="consoleout" x="270" y="648">ConsoleOut — “I print”</text>
</g>
<!-- side note: who holds the topology. Two lines, and below the frame:
one line ran past the viewBox in German and French, and an svg root
clips instead of overflowing, which truncated the label. -->
<text class="t-warn" data-label="topology" x="14" y="702">No capability names another one.</text>
<text class="t-warn" data-label="topology2" x="14" y="718">The topology lives only in the two mediators, started in main().</text>
</svg>