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

◆ mutate()

bool MayaFlux::Nodes::HookList::mutate ( const std::function< bool(std::vector< HookEntry > &)> &  edit)
private

Definition at line 111 of file NodeUtils.cpp.

112{
113 for (;;) {
114 m_readers.fetch_add(1);
115
116 const std::vector<HookEntry>* current = m_head.load();
117
118 auto next = std::make_unique<std::vector<HookEntry>>();
119 if (current) {
120 *next = *current;
121 }
122
123 const bool changed = edit(*next);
124 bool swapped = false;
125 if (changed) {
126 const std::vector<HookEntry>* replacement = next->empty() ? nullptr : next.get();
127 const std::vector<HookEntry>* expected = current;
128 swapped = m_head.compare_exchange_strong(expected, replacement);
129 if (swapped && replacement) {
130 next.release();
131 }
132 }
133
134 m_readers.fetch_sub(1);
135
136 if (!changed) {
137 return false;
138 }
139 if (swapped) {
140 if (current) {
142 }
143 reclaim();
144 return true;
145 }
146 }
147}
glm::vec2 current
std::atomic< const std::vector< HookEntry > * > m_head
void retire(const std::vector< HookEntry > *old)
Definition NodeUtils.cpp:78
std::atomic< uint32_t > m_readers

References current, m_head, m_readers, reclaim(), and retire().

Referenced by add(), add_conditional(), add_conditional_unique(), add_unique(), clear(), remove(), remove_by_condition_key(), remove_by_key(), remove_by_tag(), and remove_first_by_key().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: