The repository with the demo code for my talk Structured Concurrency in Action.
dev.nipafx.scia.queue.
The intended order for the slides and the code in this repo:
- slides: "API Overview"
- code:
BasicUse - code:
Joiners - slides: "Interruption"
- code:
Interruption - code:
Timeout - slides: "Backpressure"
- code: package
queue - code:
Items - code:
Backpressure - slides: "Building Blocks"
- code:
Resilience4j - code:
Reactive
- start with the simplest demo:
demo()open()fork()without subtasksjoin()without error handling
- use tasks:
runAll()- observe: calling a void method that throws exceptions is painful
- get result from changed state (i.e. not return value)
- switch to subtasks:
computeAll()- get result from subtask
- observe: state changes can still be observed if necessary
- thread dump:
threadDump()- increase run times and create thread dump
- observe
"virtual": true,"owner": "...", and"tid": "..."
- start error handling:
observeErrors- catch
FaledExceptionfromjoin() - observe: in the default approach, there's no access to subtasks in the catch block
- observe:
CANCELEDstate of last task
- catch
- roll back centrally:
rollbackErrors()- move
join()into its owntry - query subtask state in
catchto roll back - observe: querying subtasks for their state is complicated but may be necessary in complex scenarios
- move
- roll back per task:
rollbackLocally()+computeOrRollBack(...)- assuming each task can handle errors itself without further input, create
Task::computeOrRollBack - observe:
computeOrRollBackshould probably be part ofTask, i.e. ideally the tasks are self-correcting
- assuming each task can handle errors itself without further input, create
- start with
observeCancellation()- observe immediate return after failure
- observe
CANCELEDstate - show
InterruptedExceptionhandling inTask::run
- run busy in
observeNoCancellation()- observe delay between failure message and state message
- explain
join()vsclose() - update run-busy in
Threadto check interruption status
- timeouts in
joinEarly()- use configuration to join early
- explain when timer starts counting
- explain
join()vsclose()does not change
- more configuration in
configure()- configure scope name
- mention configuration of thread factory, e.g.:
- thread names
- uncaught exception handler
- instrumentation of the factory for metrics and logging