[Development] qt_add/removeObject hooks

Thiago Macieira thiago.macieira at intel.com
Tue Apr 15 17:02:56 CEST 2014


Em ter 15 abr 2014, às 09:49:53, Matthew Woehlke escreveu:
> If you add the rule that callbacks can't be removed once registered, you 
> could do an atomic exchange of the old callback for the new, and require 
> that any attached callback calls the previously-registered callback 
> also. (This would cost a compare per callback though in case the old is 
> null.) This takes a small amount of cleverness at the call site to 
> ensure that the pointer to old is written at the same time as the new 
> callback is registered, but should be doable. (Depending on available 
> intrinsics, you might need to do a CAS loop to first set your old, then 
> register your own callback if no one else has done so in the mean time. 
> Retry as needed. Under the circumstances, it's pretty unlikely you'd 
> ever get stuck in an infinite loop doing this.)

In other words: use QBasicAtomicPointer.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list