Quantcast
Channel: Misunderstanding of atomic structs and pointers - Stack Overflow
Browsing index pages (4 articles)

Misunderstanding of atomic structs and pointers

My first question is: Is there any way to access the members of struct in an atomic<struct> object? For example, I get the compiler error:struct std::atomic<node>’ has no member named...

View Article


Answer by Sergey Kalinichenko for Misunderstanding of atomic structs and...

this [workaround] doesn't seem very elegant.std::atomic<T> cannot make arbitrary operations atomic: only loading and storing the data is supported. That is why your "workaround" is actually the...

View Article


Answer by VAndrei for Misunderstanding of atomic structs and pointers

When you doatomic<node> a;node temp; // use a.load() to copy all the fields of a to temptemp.data = 0;a.store(temp);you loose the value of next field. I'd make the suggested change. If node would...

View Article

Answer by Peter Cordes for Misunderstanding of atomic structs and pointers

Note that your "solution" includes a non-atomic read-modify-write of all the members other than .data. atomic<node> a;node temp = a.load();temp.data = 0;a.store(temp); // steps on any changes to...

View Article
Browsing index pages (4 articles)


Latest Images