[tracker] TrackerCrawler: Add throttling in there as well.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] TrackerCrawler: Add throttling in there as well.
- Date: Fri, 18 Sep 2009 12:07:51 +0000 (UTC)
commit 349a22a435dd1ee69020de47826f70a1cb8d2d74
Author: Carlos Garnacho <carlos lanedo com>
Date: Fri Sep 18 14:02:57 2009 +0200
TrackerCrawler: Add throttling in there as well.
src/libtracker-miner/tracker-crawler.c | 29 +++++++++++++++++++++++++++++
src/libtracker-miner/tracker-crawler.h | 6 ++++++
src/libtracker-miner/tracker-miner-fs.c | 3 ---
3 files changed, 35 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-crawler.c b/src/libtracker-miner/tracker-crawler.c
index c4a25a8..264553a 100644
--- a/src/libtracker-miner/tracker-crawler.c
+++ b/src/libtracker-miner/tracker-crawler.c
@@ -51,6 +51,8 @@ struct TrackerCrawlerPrivate {
/* Idle handler for processing found data */
guint idle_id;
+ gdouble throttle;
+
gboolean recurse;
/* Statistics */
@@ -766,3 +768,30 @@ tracker_crawler_resume (TrackerCrawler *crawler)
g_message ("Crawler is resuming, %s",
crawler->private->is_running ? "currently running" : "not running");
}
+
+void
+tracker_crawler_set_throttle (TrackerCrawler *crawler,
+ gdouble throttle)
+{
+ g_return_if_fail (TRACKER_IS_CRAWLER (crawler));
+
+ throttle = CLAMP (throttle, 0, 1);
+ crawler->private->throttle = throttle;
+
+ /* Update timeouts */
+ if (crawler->private->idle_id != 0) {
+ guint interval, idle_id;
+
+ interval = MAX_TIMEOUT_INTERVAL * crawler->private->throttle;
+
+ g_source_remove (crawler->private->idle_id);
+
+ if (interval == 0) {
+ idle_id = g_idle_add (process_func, crawler);
+ } else {
+ idle_id = g_timeout_add (interval, process_func, crawler);
+ }
+
+ crawler->private->idle_id = idle_id;
+ }
+}
diff --git a/src/libtracker-miner/tracker-crawler.h b/src/libtracker-miner/tracker-crawler.h
index c3e730a..f3ee9cd 100644
--- a/src/libtracker-miner/tracker-crawler.h
+++ b/src/libtracker-miner/tracker-crawler.h
@@ -33,6 +33,9 @@ G_BEGIN_DECLS
#define TRACKER_IS_CRAWLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_CRAWLER))
#define TRACKER_CRAWLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_CRAWLER, TrackerCrawlerClass))
+/* Max timeouts time (in msec) */
+#define MAX_TIMEOUT_INTERVAL 1000
+
typedef struct TrackerCrawler TrackerCrawler;
typedef struct TrackerCrawlerClass TrackerCrawlerClass;
typedef struct TrackerCrawlerPrivate TrackerCrawlerPrivate;
@@ -68,6 +71,9 @@ void tracker_crawler_stop (TrackerCrawler *crawler);
void tracker_crawler_pause (TrackerCrawler *crawler);
void tracker_crawler_resume (TrackerCrawler *crawler);
+void tracker_crawler_set_throttle (TrackerCrawler *crawler,
+ gdouble throttle);
+
G_END_DECLS
#endif /* __LIBTRACKERMINER_CRAWLER_H__ */
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 55a2907..86bb0fd 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -28,9 +28,6 @@
#include "tracker-monitor.h"
#include "tracker-utils.h"
-/* Max timeouts time (in msec) */
-#define MAX_TIMEOUT_INTERVAL 1000
-
#define TRACKER_MINER_FS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_MINER_FS, TrackerMinerFSPrivate))
typedef struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]