Commit 8ae1bc27 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Thumbnailer: Ensure a single thread will be created

Or rather that concurrent thumbnail request won't cause the 2nd thread
to call std::terminate

(cherry picked from commit 690cdb97)
Signed-off-by: 's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent a4a949d5
Pipeline #5267 failed with stages
in 66 minutes and 23 seconds
...@@ -515,6 +515,8 @@ public: ...@@ -515,6 +515,8 @@ public:
* will be called. * will be called.
* In case a thumbnail was already generated for the media, false will be returned. * In case a thumbnail was already generated for the media, false will be returned.
* If so, no callback will be invoked * If so, no callback will be invoked
*
* This function is thread-safe
*/ */
virtual bool requestThumbnail( MediaPtr media ) = 0; virtual bool requestThumbnail( MediaPtr media ) = 0;
......
...@@ -54,10 +54,9 @@ ThumbnailerWorker::~ThumbnailerWorker() ...@@ -54,10 +54,9 @@ ThumbnailerWorker::~ThumbnailerWorker()
void ThumbnailerWorker::requestThumbnail( MediaPtr media ) void ThumbnailerWorker::requestThumbnail( MediaPtr media )
{ {
{ std::unique_lock<compat::Mutex> lock( m_mutex );
std::unique_lock<compat::Mutex> lock( m_mutex );
m_tasks.push( std::move( media ) ); m_tasks.push( std::move( media ) );
}
if ( m_thread.get_id() == compat::Thread::id{} ) if ( m_thread.get_id() == compat::Thread::id{} )
{ {
m_run = true; m_run = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment