Monads Meet Mutexes
Traditional synchronization primitives in C++-like mutex and condition_variable-often lead to verbose, error-prone code, especially when coordinating access to multiple resources under complex conditions. In this talk, we introduce SynchronizedResource, a monadic wrapper that encapsulates synchronization logic in a composable, expressive interface inspired by std::optional and std::expected.
This pattern enables safe chaining of operations while enforcing invariants at compile time. Developers can handle timeouts, predicates, and resource access with minimal boilerplate and clearer intent. For example:
auto result = resource.waitFor(timeout, pred)
.andThen([](auto& val){ /* use val */ })
.orElse([](auto&){ /* handle timeout */ });
Used in production for mass spectrometry instrument control, SynchronizedResource has improved code clarity, robustness, and maintainability - without introducing excessive template complexity. Attendees will learn how monadic synchronization can simplify concurrent C++ code and reduce subtle bugs in real-world systems.

Arne Berger
Arne (he/him) is a C++ developer at Bruker Daltonics, building control software for mass spectrometry instruments. With more than 10 years of experience in C++ and a solid background in optimization and optimal control, he’s all about writing clean, reliable code. He enjoys designing libraries that make life easier for developers and help teams avoid the usual coding headaches.
