[solang] Invoke Thumbnailer::process only when there is a pending request



commit d685caa45f673df491caef23c7a716978fed4b9d
Author: Debarshi Ray <rishi gnu org>
Date:   Wed Mar 10 08:00:20 2010 +0200

    Invoke Thumbnailer::process only when there is a pending request
    
    The Thumbnailer::process method was getting invoked after every 100 ms
    even when there were no pending thumbnail requests. Instead, when the
    first request is pushed into an empty queue, it should be run once
    after the expiry of the timeout interval.

 src/common/thumbnailer.cpp |   28 +++++++++-------------------
 src/common/thumbnailer.h   |    6 ++----
 2 files changed, 11 insertions(+), 23 deletions(-)
---
diff --git a/src/common/thumbnailer.cpp b/src/common/thumbnailer.cpp
index 1ab03cc..34746ba 100644
--- a/src/common/thumbnailer.cpp
+++ b/src/common/thumbnailer.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 /*
- * Copyright (C) 2009 Debarshi Ray <rishi gnu org>
+ * Copyright (C) 2009, 2010 Debarshi Ray <rishi gnu org>
  *
  * Solang is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -49,7 +49,6 @@ Thumbnailer::Thumbnailer() throw() :
 
 Thumbnailer::~Thumbnailer() throw()
 {
-    signalTimeout_.disconnect();
 }
 
 void
@@ -113,14 +112,9 @@ Thumbnailer::on_signal_started(guint handle) throw()
 {
 }
 
-bool
+void
 Thumbnailer::process() throw()
 {
-    if (true == pendingList_.empty())
-    {
-        return true;
-    }
-
     UStringList mime_types;
     UStringList uris;
 
@@ -142,24 +136,20 @@ Thumbnailer::process() throw()
                                  &Thumbnailer::on_async_queue),
                    pendingList_));
     pendingList_.clear();
-
-    return true;
 }
 
 void
 Thumbnailer::push(const PhotoPtr & photo) throw()
 {
-    pendingList_.push_back(photo);
-
-    if (0 == signalTimeout_)
+    if (true == pendingList_.empty())
     {
-        signalTimeout_
-            = Glib::signal_timeout().connect(
-                  sigc::mem_fun(*this,
-                                &Thumbnailer::process),
-                  100,
-                  Glib::PRIORITY_DEFAULT);
+        Glib::signal_timeout().connect_once(
+            sigc::mem_fun(*this, &Thumbnailer::process),
+            100,
+            Glib::PRIORITY_DEFAULT);
     }
+
+    pendingList_.push_back(photo);
 }
 
 sigc::signal<void, PhotoList &> &
diff --git a/src/common/thumbnailer.h b/src/common/thumbnailer.h
index a133fbc..836f6a4 100644
--- a/src/common/thumbnailer.h
+++ b/src/common/thumbnailer.h
@@ -1,6 +1,6 @@
 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 /*
- * Copyright (C) 2009 Debarshi Ray <rishi gnu org>
+ * Copyright (C) 2009, 2010 Debarshi Ray <rishi gnu org>
  *
  * Solang is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -66,7 +66,7 @@ class Thumbnailer :
         void
         on_signal_started(guint handle) throw();
 
-        bool
+        void
         process(void) throw();
 
         std::map<guint, std::map<Glib::ustring, PhotoPtr> > map_;
@@ -75,8 +75,6 @@ class Thumbnailer :
 
         ThumbnailerProxy thumbnailerProxy_;
 
-        sigc::connection signalTimeout_;
-
         sigc::signal<void, PhotoList &> ready_;
 };
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]