C++ Logo

std-proposals

Advanced search

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

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Fri, 7 Jul 2023 17:33:33 +0200
> If the committee decides to make Data's members private by default, then using an accessor-method, we can safely > share the Data struct member with other fibers. This is similar to how we can share a std::shared_ptr<> with other > threads. That is not exactly true: Each thread needs a new shared_ptr. You cannot just share the shared_ptr itself. That would not be thread safe at all. The first shared_ptr can be assigned to the dedicated shared_ptrs within the other threads, so all shared_ptr to the one object can share a control block. By using this method, only the deletion/destruction of the underlying object is made thread safe. Accesses to the object are neither made thread safe by one shared_ptr nor multiple shared_ptr. Const-only accesses probably would work, but otherwise you need a synchronization mechanism.   -----Ursprüngliche Nachricht----- Von:1one1 via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Fr 07.07.2023 17:06 Betreff:Re: [std-proposals] Proposal for ‘std::fiber<T>‘ Language-level Extension in C++23 An:std-proposals_at_[hidden]; CC:1one1 <ahshabazz_at_[hidden]>; I would like to stay on the topic of my proposal, because the use and or usefulness of large language models is still being debated by society ... In this next API call example, ```struct Data { int id; std::vector<int> numbers }; std::fiber<Data> _fiber_;```, we're creating a std::fiber<> wrapper for a Data struct. Each fiber can independently processes its own Data struct.   Since std::fiber<Data> employs RCU or COW semantics, it can safely read from Data.id, Data.numbers, etc. without causing any data races. Also, if a fiber needs to modify its Data member, it will only copy the parts of the data that it's going to modify (lazy copying), which helps to optimize memory usage.   If the committee decides to make Data's members private by default, then using an accessor-method, we can safely share the Data struct member with other fibers. This is similar to how we can share a std::shared_ptr<> with other threads.   ```// Each fiber reads and updates the commonNumber via accessor methods // int localCopy = _fiber_.read(OtherSharedData.commonNumber); localCopy += 1;  // Increment our local copy // _fiber_.write(OtherSharedData.commonNumber, localCopy);  // Write back to shared data //```   Moreover, with deterministic memory management (like reference counting), we can ensure aggregates, such as in ```std::vector<std::fiber<Data>> _fibers_;``` are not prematurely deleted when they are still being used by the fibers.   Hopefully, this example showcases the simplicity and clarity of the std::fiber<T> API, making it easy for developers to create and manage. Regards, Abdul S. On Friday, July 7, 2023, 10:39, Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]> wrote: There is a reason, why current language models are frowned upon, when the users just rely on them instead of understanding _and_ checking the subject topics.   They are forbidden on stackoverflow.com (https://meta.stackoverflow.com/questions/421831/temporary-policy-generative-ai-e-g-chatgpt-is-banned), lawyers could get sanctioned for not checking their submissals (https://lsj.com.au/articles/lawyer-faces-sanctions-for-using-bogus-citations-from-chatgpt/), etc.   If you do not even invest the time to check the answers on this mailing list and the link references yourself, you are wasting everyone's else's time. So please, even if you let yourself help by ChatGPT, you have to read, understand and improve upon the topics, you are providing proposals for, in depth! Perhaps you think, you are smart, just using those tools, when actually it is kind of fake, if you do not use a disclaimer in your messages and in your proposal that it actually has not been fully written by yourself.       -----Ursprüngliche Nachricht----- Von:1one1 via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Fr 07.07.2023 15:51 Betreff:Re: [std-proposals] Proposal for ‘std::fiber<T>‘ Language-level Extension in C++23 An:Jonathan Wakely via Std-Proposals <std-proposals_at_[hidden]>; Bjorn Reese <breese_at_[hidden]>; CC:1one1 <ahshabazz_at_[hidden]>; Thanks for the URL Bjorn. I will supply the link to my OpenAI GPT Model to further help me hone the key concepts of my proposal. If there are any mistakes in this proposal which need correcting, they are my own!  And the very gifted people on this standards committee need to stop denigrating other members whom use these large language models to better clarify their ideas; It's like Einstein bullying the kid in the back of the class room because he uses a calculator, admonishing him to properly attribute his to Casio or Texas Instruments...  Regards, Abdul S.   -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals  

Received on 2023-07-07 15:33:35