how to put struct to queue
chansonZ opened this issue · comments
chanson commented
Can anyone help?
typedef struct {
int a;
char b[32];
} UserData;
compile error when:
constexpr unsigned CAPACITY = 1024;
AtomicQueue<UserData, CAPACITY> q;
Maxim Egorushkin commented
When you report problems, you should provide a complete reproducible example with the error message, so that no guesswork or undue effort is required to help you.
Your code doesn't compile because you use queue template AtomicQueue
designed for atomic elements, whereas UserData
isn't one.
Queue template AtomicQueue2
, on the other hand, is designed for non-atomic elements and that is what you should use:
AtomicQueue2<UserData, CAPACITY> q;
You should always read documentation before using something or asking questions. 15 minutes spent on reading documentation saves you endless hours of debugging.