stlab libraries
Modern, modular C++ algorithms and data structures. Source and issues on GitHub.
|
API
|
Concurrency
|
Forest
|
Latest Release: v3.0.0
Released: Oct 29, 2026Sources: changes | zipball | tarball
Changes:
Highlights
- Fix broken-promise handling in
when_allandwhen_any, including executors that discard queued work. Join bookkeeping no longer requires a recovery shared state for each input. (#612) - Preserve future value forwarding and executor lifetimes across recovery, completion, and coroutine suspension. (#609)
- Correct producer replacement, move-only value extraction, and coroutine results containing
std::exception_ptr. (#609)
Breaking changes and migration
This major release changes future extraction and detachment contracts and removes deprecated APIs.
- For move-only futures, call
f.get_try()on a mutable lvalue for nonblocking polling. A successful poll moves out the value; a pending poll preserves the future. When readiness is known, usestd::move(f).get_ready(). Const extraction is no longer supported. Copyable futures retain non-destructive shared-value extraction. detach()is now rvalue-only. Replacef.detach()on a named future withstd::move(f).detach(). The detached future is retained until completion.- Replace
blocking_getwithawait, andblocking_get_forwithawait_for. For timed value extraction, retain the future returned byawait_forand use the appropriate extraction operation. - Replace
error()withis_ready()followed byexception(), or userecover()for continuation-based error handling. when_anyselects the first successful input observed by completion bookkeeping, rather than by executor notification order. If every input fails, it reports the last observed failure.
Draft publication checklist
- Confirm Build and Tests passes for release candidate
35197e5d81ebf6afe4a74dd833fd34a5ff55d005. The run was still in progress when this draft was prepared. - Doxygen API docs and documentation-site deployment succeeded for the release candidate.
What’s Changed
- Address Coverity findings and preserve future value forwarding by @sean-parent in https://github.com/stlab/stlab/pull/609
- Fix broken-promise handling in future joins by @sean-parent in https://github.com/stlab/stlab/pull/612
Full Changelog: https://github.com/stlab/stlab/compare/v2.4.0…v3.0.0
For older releases, the full list is available on GitHub.Posts
-
Forest: An Introduction
Hierarchies. Everyone uses them, so why are they difficult to maintain? In this article we explore
forest, a data structure that makes hierarchies self-maintainable, so you can go back to thinking about the data they contain. -
Small Object Optimization for Polymorphic Types
At Meeting C++ 2017 I presented a lightning talk Polymorphic Task Template in Ten which showed an easy way to implement a polymorphic task template, similar to
std::function, with a small object optimization in 10 minutes.Unfortunately, the small object optimization, as described, leads to undefined behavior. As a general rule, you cannot store an object of one type in memory and read it back as another, even if the other type is the objects base class (there are exceptions to this rule, but they do not apply to this situation).
This tip looks at the details of the issue and describes a solution which turns out to be more efficient although it does require slightly more, and more complex, code to implement. A small object optimization for polymorphic types is a very useful construct so it important to understand how it can be done correctly.
-
New Concurrency Library
A new concurrency library was added as a first one to this new stlab instance.
This library provides an alternative to the C++11/14 and upcoming C++17 TS futures. As well it provides an implementation of channels that allow the creation of process graphs.
subscribe via RSS