31 Jul
2014
31 Jul
'14
8:23 a.m.
On Wed, Jul 30, 2014 at 11:36 AM, Peter Dimov
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.
If a copy of the new value is passed as argument to the callbacks, then I don't see the problem - except the cost of the copy of course.