Commit b999335
committed
Virtual threads to isolate ThreadLocals in hooks.
There's something kind of funny about going to great lengths to use our
Reactive Breadth First Search algorithm to achieve the hook ordering we
want without using a background thread, and then right at the last
moment, spawning a thread to run each hook anyway.
I'm leaving it this way for the time being because it has certain
desirable properties:
- The hook queue maintains the desired order. In contrast, if we simply
submitted the hooks to an executor, all bets are off.
- Only one hook runs at a time. There's a happens-before relationship
between all the hooks.
In effect, since we're running completely synchronously with the virtual
thread, using it as a kind of structured concurrency sans parallelism,
we're actually just using the virtual thread mechansim as a utility to
isolate ThreadLocals and nothing else.
Anyway, this is a step closer to the semantics we want, and we can
refine the implementation later if we can devise a simpler way to
achieve all the desired properties.1 parent 9379c22 commit b999335
File tree
2 files changed
+38
-1
lines changed- bosk-core/src
- main/java/works/bosk
- test/java/works/bosk
2 files changed
+38
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| 95 | + | |
92 | 96 | | |
93 | 97 | | |
94 | 98 | | |
| |||
542 | 546 | | |
543 | 547 | | |
544 | 548 | | |
545 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
546 | 554 | | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
547 | 566 | | |
548 | 567 | | |
549 | 568 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
81 | 99 | | |
82 | 100 | | |
83 | 101 | | |
| |||
0 commit comments