30 Jul
2014
30 Jul
'14
9:36 a.m.
Andrey Semashev wrote:
The problem with the callbacks is that you have to choose the thread to invoke them in. In the simplest case this could be the writer thread, in other cases a separate thread pool might be more desirable.
I'd say that the problem with the callback architecture is that you still need to communicate the change to the readers, which would require them to still poll an atomic variable at the very least. And if they poll, there's no need for callbacks. Just have the writer increment a version counter. weak_ptr's would be slightly less performant because they do a CAS on lock, instead of just an atomic read. I'm not sure if this would matter that much though.