From 37ea6a73809a083861e6fa093e2ecac42e251c44 Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Thu, 28 Oct 2010 21:47:52 +0200 Subject: [PATCH] Using Steves threadsafe DCRAW to roughly double thumbnail generation speed on multicore CPUs. Now there are two update worker threads. Easy to remove if someone provides code for a more efficient distribution mechanism. --- rtgui/filecatalog.cc | 22 ++++++++++++++++++++++ rtgui/filecatalog.h | 28 +++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index 1adb54e69..b25e6739a 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -970,3 +970,25 @@ bool FileCatalog::handleShortcutKey (GdkEventKey* event) { return false; } +void PreviewMultiLoader::setPreviewLoaderListener (PreviewLoaderListener* p) { + loadA.setPreviewLoaderListener(p); loadB.setPreviewLoaderListener(p); +} + +// Simple round robin +void PreviewMultiLoader::add(DirEntry de) { + if (next==0) { + loadA.add(de); + next=1; + } else { + loadB.add(de); + next=0; + } +} + +void PreviewMultiLoader::start () { loadA.start(); loadB.start(); } +void PreviewMultiLoader::process () { loadA.process (); loadB.process(); } +void PreviewMultiLoader::remove (Glib::ustring fname) { loadA.remove(fname); loadB.remove(fname); } +void PreviewMultiLoader::end () { loadA.end(); loadB.end(); } +bool PreviewMultiLoader::runs () { return loadA.runs() || loadB.runs(); } +void PreviewMultiLoader::terminate () { loadA.terminate(); loadB.terminate(); } +void PreviewMultiLoader::stop () { loadA.stop(); loadB.stop(); } diff --git a/rtgui/filecatalog.h b/rtgui/filecatalog.h index f7e95ac4f..a3d7b9b15 100644 --- a/rtgui/filecatalog.h +++ b/rtgui/filecatalog.h @@ -67,6 +67,30 @@ class PreviewLoader : public ProcessingThread { void end (); }; +// Simple Multithreader: Harnesses two normal loader threads feeded by a round robin +// Same interface as a normal PreviewLoader to minimize effects on code +class PreviewMultiLoader { +protected: + PreviewLoader loadA,loadB; + int next; + +public: + PreviewMultiLoader () { next=0; } + + void setPreviewLoaderListener (PreviewLoaderListener* p); + + void add (DirEntry de); + + void start (); + void process (); + void remove (Glib::ustring fname); + void end (); + + bool runs (); + void terminate (); + void stop (); +}; + class FileCatalog : public Gtk::VBox, public DirSelectionListener, public PreviewLoaderListener, @@ -82,7 +106,9 @@ class FileCatalog : public Gtk::VBox, Glib::ustring selectedDirectory; bool enabled; - PreviewLoader previewLoader; + // Restore PreviewLoader if the new threadsafe is not that threadsafe ;-) + //PreviewLoader previewLoader; + PreviewMultiLoader previewLoader; FileSelectionListener* listener; FileSelectionChangeListener* fslistener; ImageAreaToolListener* iatlistener;