C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal for `std::fiber<T>` Language-Level Extension in C++23

From: 1one1 <ahshabazz_at_[hidden]>
Date: Fri, 7 Jul 2023 07:20:56 +0000 (UTC)
The concept as proposed is quite novel, and may not have an exact counterpart in existing libraries.
However, certain elements of the proposal can be found separately in various libraries and projects:
    Concurrency with Fibers: Boost library provides boost::fibers, which implements a form of cooperative multitasking on a single thread, somewhat similar to what we discussed for std::fiber<T>. Documentation and examples are available on the Boost.Fiber documentation page.
    Copy-on-Write (COW): You can find many C++ projects implementing COW semantics for specific use cases, such as COW string optimization in STL implementations. However, keep in mind that this pattern may not scale well for complex, large data structures.
    Read-Copy-Update (RCU): RCU is commonly used in kernel programming. The Userspace RCU library (liburcu) is a C implementation of RCU that could be studied for its semantics, though it's not designed specifically for C++ or the fiber model we've discussed.
    Lock-Free and Concurrent Data Structures: Libraries like Concurrent Data Structures (CDS) and Intel Threading Building Blocks (TBB) offer various concurrent and lock-free data structures that could be instructive for thinking about thread-safe data management.
Each of these elements provides a piece of the std::fiber<T> puzzle but does not fully realize the proposed concept. The creation of a std::fiber<T> library would likely require combining and extending these techniques in new ways.
Please note that while these resources can provide a good start, the task of combining these techniques to mimic std::fiber<T> is nontrivial.

Regards,Abdul S.
On Friday, July 7, 2023, 03:08, Thiago Macieira via Std-Proposals <std-proposals_at_[hidden]> wrote:

On Friday, 7 July 2023 00:05:20 PDT 1one1 via Std-Proposals wrote:
> ## Motivation and Scope
> Concurrent programming is a challenging aspect of C++, requiring careful
> synchronization to avoid data races and associated undefined behavior. This
> proposal seeks to mitigate these challenges by introducing a unit of
> execution, `std::fiber<T>`, designed with built-in Read-Copy-Update (RCU)
> or Copy-On-Write (COW) semantics to handle shared state. This approach
> simplifies concurrent programming, allowing programmers to reason about
> each fiber's execution as if it were single-threaded, whilst the complexity
> of managing shared state is handled by the language or runtime.

Please include a link to a library with at least 3 years of real-world
experience implementing this functionality. Until you have such a link, I
doubt it'll be considered even for debate.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Software Architect - Intel DCAI Cloud Engineering
-- 
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2023-07-07 07:21:07