MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ push()

template<typename T >
void MayaFlux::Memory::SweepList< T >::push ( T  value)
inlinenoexcept

Publishes value for later sweep() or drain().

Safe to call from any number of concurrent threads. Allocates one link; the link is freed when the item is reclaimed by sweep() or drain().

Parameters
valueItem to retain. Moved into internal storage.

Definition at line 98 of file SweepList.hpp.

99 {
100 std::unique_ptr<Link> owned = std::make_unique<Link>(std::move(value), nullptr);
101
102 // The atomic word alone decides ownership from here: once the CAS
103 // below succeeds, m_head is the link's only owner. release() marks
104 // that handoff explicitly rather than leaving a raw pointer implied.
105 Link* node = owned.release();
106
107 node->next = m_head.load(std::memory_order_relaxed);
108 while (!m_head.compare_exchange_weak(
109 node->next, node,
110 std::memory_order_release, std::memory_order_relaxed)) {
111 }
112
113 m_count.fetch_add(1, std::memory_order_relaxed);
114 }
glm::vec3 value
std::atomic< Link * > m_head
std::atomic< size_t > m_count

References MayaFlux::Memory::SweepList< T >::m_count, MayaFlux::Memory::SweepList< T >::m_head, MayaFlux::Memory::SweepList< T >::Link::next, and value.

Referenced by MayaFlux::Parallel::AsyncGroup< T >::report().

+ Here is the caller graph for this function: