medialib: improve starting
commit4e7a6b4fa982f9737d27b07701758809083682d6
authorRomain Vimont <rom1v@videolabs.io>
Wed, 6 Jan 2021 12:45:59 +0000 (6 13:45 +0100)
committerHugo Beauzée-Luyssen <hugo@beauzee.fr>
Mon, 25 Jan 2021 17:42:56 +0000 (25 18:42 +0100)
tree1bcf8444d1c06f212a153886bfd5dff39087590f
parente00cf4e8c997bed4873a65d7795fd05c2e32770b
medialib: improve starting

Some controls request to "start" the medialibrary (start to discover
some folders) if not already started. The actual starting should be done
at most once.

The fact that it was already started relied on the number of entry
points, which can only be known by executing SQL queries. For
asynchronous controls, this caused the execution of SQL queries on the
UI thread for every control requesting the medialibrary to be "started".

To avoid this unnecessary performance issue, add a simple atomic flag.

Signed-off-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
modules/misc/medialibrary/medialibrary.cpp
modules/misc/medialibrary/medialibrary.h