- bool insertHead(T* t) {
- assert(next(t) == nullptr);
-
- auto oldHead = head_.load(std::memory_order_relaxed);
- do {
- next(t) = oldHead;
- /* oldHead is updated by the call below.
-
- NOTE: we don't use next(t) instead of oldHead directly due to
- compiler bugs (GCC prior to 4.8.3 (bug 60272), clang (bug 18899),
- MSVC (bug 819819); source:
- http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange */
- } while (!head_.compare_exchange_weak(oldHead, t,
- std::memory_order_release,
- std::memory_order_relaxed));
-
- return oldHead == nullptr;
+ bool insertHead(T t) {
+ auto wrapper = std::make_unique<Wrapper>(std::move(t));
+
+ return list_.insertHead(wrapper.release());