Open jrahlf opened 3 years ago
Overwiriting insert is wanted function especially in atomic context. Probably as separate function instead of overloading. I'll definitely add it in mpmc, but non atomic overloads of insert is going to be a lot of burden now.
It is still possible to inherit from the spsc class and add followinfg function
//non atomic, returns true if overwritten
bool insertOverwrite(T data)
{
if(!insert(data)) {
remove();
insert(data);
return true;
}
return false;
}
not the most efficient, but should work.
Hi,
how about adding a template parameter which makes it an overwriting ring buffer? I.e. when buffer is full, calling insert() replaces the oldest value with the new value. Then the tail also has to be updated, which means the ring buffer cannot be lock free anymore.
I really like your implementation and this addition would make it even more generalized.