[Kde-hardware-devel] Review Request 109521: Introduce a cache for backend objects in the right place

Alexander Mezin mezin.alexander at gmail.com
Sat Mar 16 15:31:04 UTC 2013


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/109521/
-----------------------------------------------------------

Review request for Solid.


Description
-------

Current cache in UDisks2 has two problems: it isn't thread-safe and it introduces "backend objects" for objects that are backends themselves.

Backends and interfaces created through Solid::Device are already shared in thread-safe way, and I think it's better to use this for caching. Also, if DevicePrivates will be cached, all Iface objects will be cached too. The only thing needed is QMap with strong pointers to keep DevicePrivates alive.
This way DeviceBackends could be eliminated. Also, this cache could be easily used by another backends. 

The only problem is that objects like UDisks2::Device are sometimes explicitly created in UDisks2 backend code, but this could be fixed later. Seems that almost every time UDisks2::Device can be replaced with Solid::Device.


Diffs
-----

  solid/solid/devicemanager.cpp a465169 
  solid/solid/devicemanager_p.h 0d8bd8e 
  solid/solid/backends/udisks2/udisksmanager.h fb929ce 
  solid/solid/ifaces/devicemanager.h 3488d0b 

Diff: http://git.reviewboard.kde.org/r/109521/diff/


Testing
-------

After applying this patch to kdelibs 4.10.1, Solid::UDisks2::createDevice is called only once for every device. When the device is replaced, createDevice is called again. Tested on Dolphin using qDebug() :)
Before patching, createDevice was called multiple times.

Didn't see any regressions.


Thanks,

Alexander Mezin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-hardware-devel/attachments/20130316/14298160/attachment.html>


More information about the Kde-hardware-devel mailing list