[libcxx-commits] [libcxx] [libc++] Impelement P2545R4 Read-Copy Update (RCU) (PR #175451)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 23 11:21:20 PST 2026
================
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___RCU_RCU_LIST_H
+#define _LIBCPP___RCU_RCU_LIST_H
+
+#include <__config>
+#include <__functional/function.h>
+#include <__rcu/rcu_domain.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_THREADS && _LIBCPP_HAS_EXPERIMENTAL_RCU
+
+struct __rcu_node {
+ function<void()> __callback_{};
+ __rcu_node* __next_ = nullptr;
+};
+
+class __rcu_singly_list_view {
----------------
ldionne wrote:
I would suggest that you implement this on top of `std::forward_list`. You only need to maintain an iterator to the last alive node, and that should allow you to implement `__push_back` by doing `insert_after`.
https://github.com/llvm/llvm-project/pull/175451
More information about the libcxx-commits
mailing list