[Xfce4-commits] <tumbler:master> LIFO scheduler for interactive thumbnailing
Jannis Pohlmann
noreply at xfce.org
Tue Oct 6 20:54:01 CEST 2009
Updating branch refs/heads/master
to b2aa6175031905006c86e3ff749728ac811e1553 (commit)
from 107f638da92c8da10b3b34c8fb5ad81e1690c9cd (commit)
commit b2aa6175031905006c86e3ff749728ac811e1553
Author: Philip Van Hoof <philip at codeminded.be>
Date: Tue Oct 6 16:32:21 2009 +0200
LIFO scheduler for interactive thumbnailing
Signed-off-by: Jannis Pohlmann <jannis at xfce.org>
tumblerd/Makefile.am | 4 +-
...eshold-scheduler.c => tumbler-lifo-scheduler.c} | 238 ++++++++++----------
tumblerd/tumbler-lifo-scheduler.h | 44 ++++
tumblerd/tumbler-scheduler.c | 9 +
tumblerd/tumbler-scheduler.h | 3 +
tumblerd/tumbler-service.c | 4 +-
tumblerd/tumbler-threshold-scheduler.h | 44 ----
7 files changed, 177 insertions(+), 169 deletions(-)
diff --git a/tumblerd/Makefile.am b/tumblerd/Makefile.am
index cb09b8d..1813994 100644
--- a/tumblerd/Makefile.am
+++ b/tumblerd/Makefile.am
@@ -41,8 +41,8 @@ tumblerd_SOURCES = \
tumbler-service.h \
tumbler-specialized-thumbnailer.c \
tumbler-specialized-thumbnailer.h \
- tumbler-threshold-scheduler.c \
- tumbler-threshold-scheduler.h \
+ tumbler-lifo-scheduler.c \
+ tumbler-lifo-scheduler.h \
tumbler-utils.h \
$(tumblerd_built_sources)
diff --git a/tumblerd/tumbler-threshold-scheduler.c b/tumblerd/tumbler-lifo-scheduler.c
similarity index 57%
rename from tumblerd/tumbler-threshold-scheduler.c
rename to tumblerd/tumbler-lifo-scheduler.c
index 3cda6cf..832daab 100644
--- a/tumblerd/tumbler-threshold-scheduler.c
+++ b/tumblerd/tumbler-lifo-scheduler.c
@@ -30,7 +30,7 @@
#include <tumbler/tumbler.h>
-#include <tumblerd/tumbler-threshold-scheduler.h>
+#include <tumblerd/tumbler-lifo-scheduler.h>
#include <tumblerd/tumbler-scheduler.h>
@@ -39,56 +39,54 @@
enum
{
PROP_0,
- PROP_THRESHOLD,
+ PROP_KIND,
};
-
-
-static void tumbler_threshold_scheduler_iface_init (TumblerSchedulerIface *iface);
-static void tumbler_threshold_scheduler_finalize (GObject *object);
-static void tumbler_threshold_scheduler_get_property (GObject *object,
+static void tumbler_lifo_scheduler_iface_init (TumblerSchedulerIface *iface);
+static void tumbler_lifo_scheduler_finalize (GObject *object);
+static void tumbler_lifo_scheduler_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
-static void tumbler_threshold_scheduler_set_property (GObject *object,
+static void tumbler_lifo_scheduler_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
-static void tumbler_threshold_scheduler_push (TumblerScheduler *scheduler,
+static void tumbler_lifo_scheduler_push (TumblerScheduler *scheduler,
TumblerSchedulerRequest *request);
-static void tumbler_threshold_scheduler_unqueue (TumblerScheduler *scheduler,
+static void tumbler_lifo_scheduler_unqueue (TumblerScheduler *scheduler,
guint handle);
-static void tumbler_threshold_scheduler_finish_request (TumblerThresholdScheduler *scheduler,
+static void tumbler_lifo_scheduler_finish_request (TumblerLifoScheduler *scheduler,
TumblerSchedulerRequest *request);
-static void tumbler_threshold_scheduler_unqueue_request (TumblerSchedulerRequest *request,
+static void tumbler_lifo_scheduler_unqueue_request (TumblerSchedulerRequest *request,
gpointer user_data);
-static void tumbler_threshold_scheduler_thread (gpointer data,
+static void tumbler_lifo_scheduler_thread (gpointer data,
gpointer user_data);
-static void tumbler_threshold_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer,
+static void tumbler_lifo_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer,
const gchar *failed_uri,
gint error_code,
const gchar *message,
TumblerSchedulerRequest *request);
-static void tumbler_threshold_scheduler_thumbnailer_ready (TumblerThumbnailer *thumbnailer,
+static void tumbler_lifo_scheduler_thumbnailer_ready (TumblerThumbnailer *thumbnailer,
const gchar *uri,
TumblerSchedulerRequest *request);
-struct _TumblerThresholdSchedulerClass
+struct _TumblerLifoSchedulerClass
{
GObjectClass __parent__;
};
-struct _TumblerThresholdScheduler
+struct _TumblerLifoScheduler
{
GObject __parent__;
- GThreadPool *large_pool;
- GThreadPool *small_pool;
+ GThreadPool *pool;
GMutex *mutex;
GList *requests;
- guint threshold;
+ guint lifo;
+ gchar *kind;
};
@@ -97,78 +95,75 @@ G_LOCK_DEFINE (plugin_access_lock);
-G_DEFINE_TYPE_WITH_CODE (TumblerThresholdScheduler,
- tumbler_threshold_scheduler,
+G_DEFINE_TYPE_WITH_CODE (TumblerLifoScheduler,
+ tumbler_lifo_scheduler,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (TUMBLER_TYPE_SCHEDULER,
- tumbler_threshold_scheduler_iface_init));
+ tumbler_lifo_scheduler_iface_init));
static void
-tumbler_threshold_scheduler_class_init (TumblerThresholdSchedulerClass *klass)
+tumbler_lifo_scheduler_class_init (TumblerLifoSchedulerClass *klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = tumbler_threshold_scheduler_finalize;
- gobject_class->get_property = tumbler_threshold_scheduler_get_property;
- gobject_class->set_property = tumbler_threshold_scheduler_set_property;
+ gobject_class->finalize = tumbler_lifo_scheduler_finalize;
+ gobject_class->get_property = tumbler_lifo_scheduler_get_property;
+ gobject_class->set_property = tumbler_lifo_scheduler_set_property;
g_object_class_install_property (gobject_class,
- PROP_THRESHOLD,
- g_param_spec_uint ("threshold",
- "threshold",
- "threshold",
- 0, G_MAXUINT, 20,
- G_PARAM_READWRITE));
-
+ PROP_KIND,
+ g_param_spec_string ("kind",
+ "kind",
+ "kind",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE));
}
-
+static const gchar*
+tumbler_lifo_scheduler_get_kind (TumblerScheduler *scheduler)
+{
+ TumblerLifoScheduler *s = TUMBLER_LIFO_SCHEDULER (scheduler);
+ return s->kind;
+}
static void
-tumbler_threshold_scheduler_iface_init (TumblerSchedulerIface *iface)
+tumbler_lifo_scheduler_iface_init (TumblerSchedulerIface *iface)
{
- iface->push = tumbler_threshold_scheduler_push;
- iface->unqueue = tumbler_threshold_scheduler_unqueue;
+ iface->push = tumbler_lifo_scheduler_push;
+ iface->unqueue = tumbler_lifo_scheduler_unqueue;
+ iface->get_kind = tumbler_lifo_scheduler_get_kind;
}
static void
-tumbler_threshold_scheduler_init (TumblerThresholdScheduler *scheduler)
+tumbler_lifo_scheduler_init (TumblerLifoScheduler *scheduler)
{
scheduler->mutex = g_mutex_new ();
scheduler->requests = NULL;
- /* allocate a pool with max. 2 threads for request with <= threshold URIs */
- scheduler->small_pool = g_thread_pool_new (tumbler_threshold_scheduler_thread,
- scheduler, 2, TRUE, NULL);
+ /* allocate a pool with max. 2 threads for request with <= lifo URIs */
+ scheduler->pool = g_thread_pool_new (tumbler_lifo_scheduler_thread,
+ scheduler, 1, TRUE, NULL);
/* make the thread a LIFO */
- g_thread_pool_set_sort_function (scheduler->small_pool,
- tumbler_scheduler_request_compare, NULL);
-
- /* allocate a pool with max. 2 threads for request with > threshold URIs */
- scheduler->large_pool = g_thread_pool_new (tumbler_threshold_scheduler_thread,
- scheduler, 2, TRUE, NULL);
-
- /* make the thread a LIFO */
- g_thread_pool_set_sort_function (scheduler->small_pool,
+ g_thread_pool_set_sort_function (scheduler->pool,
tumbler_scheduler_request_compare, NULL);
}
static void
-tumbler_threshold_scheduler_finalize (GObject *object)
+tumbler_lifo_scheduler_finalize (GObject *object)
{
- TumblerThresholdScheduler *scheduler = TUMBLER_THRESHOLD_SCHEDULER (object);
+ TumblerLifoScheduler *scheduler = TUMBLER_LIFO_SCHEDULER (object);
/* destroy both thread pools */
- g_thread_pool_free (scheduler->small_pool, TRUE, TRUE);
- g_thread_pool_free (scheduler->large_pool, TRUE, TRUE);
+ g_thread_pool_free (scheduler->pool, TRUE, TRUE);
/* release all pending requests */
g_list_foreach (scheduler->requests, (GFunc) tumbler_scheduler_request_free, NULL);
@@ -179,23 +174,23 @@ tumbler_threshold_scheduler_finalize (GObject *object)
/* destroy the mutex */
g_mutex_free (scheduler->mutex);
- (*G_OBJECT_CLASS (tumbler_threshold_scheduler_parent_class)->finalize) (object);
+ (*G_OBJECT_CLASS (tumbler_lifo_scheduler_parent_class)->finalize) (object);
}
static void
-tumbler_threshold_scheduler_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+tumbler_lifo_scheduler_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- TumblerThresholdScheduler *scheduler = TUMBLER_THRESHOLD_SCHEDULER (object);
+ TumblerLifoScheduler *scheduler = TUMBLER_LIFO_SCHEDULER (object);
switch (prop_id)
{
- case PROP_THRESHOLD:
- g_value_set_uint (value, scheduler->threshold);
+ case PROP_KIND:
+ g_value_set_string (value, scheduler->kind);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -206,17 +201,17 @@ tumbler_threshold_scheduler_get_property (GObject *object,
static void
-tumbler_threshold_scheduler_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+tumbler_lifo_scheduler_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- TumblerThresholdScheduler *scheduler = TUMBLER_THRESHOLD_SCHEDULER (object);
+ TumblerLifoScheduler *scheduler = TUMBLER_LIFO_SCHEDULER (object);
switch (prop_id)
{
- case PROP_THRESHOLD:
- scheduler->threshold = g_value_get_uint (value);
+ case PROP_KIND:
+ scheduler->kind = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -227,67 +222,64 @@ tumbler_threshold_scheduler_set_property (GObject *object,
static void
-tumbler_threshold_scheduler_push (TumblerScheduler *scheduler,
- TumblerSchedulerRequest *request)
+tumbler_lifo_scheduler_push (TumblerScheduler *scheduler,
+ TumblerSchedulerRequest *request)
{
- TumblerThresholdScheduler *threshold_scheduler =
- TUMBLER_THRESHOLD_SCHEDULER (scheduler);
+ TumblerLifoScheduler *lifo_scheduler =
+ TUMBLER_LIFO_SCHEDULER (scheduler);
- g_return_if_fail (TUMBLER_IS_THRESHOLD_SCHEDULER (scheduler));
+ g_return_if_fail (TUMBLER_IS_LIFO_SCHEDULER (scheduler));
g_return_if_fail (request != NULL);
- g_mutex_lock (threshold_scheduler->mutex);
+ g_mutex_lock (lifo_scheduler->mutex);
/* gain ownership over the requests (sets request->scheduler) */
tumbler_scheduler_take_request (scheduler, request);
/* prepend the request to the request list */
- threshold_scheduler->requests =
- g_list_prepend (threshold_scheduler->requests, request);
+ lifo_scheduler->requests =
+ g_list_prepend (lifo_scheduler->requests, request);
- /* enqueue the request in one of the two thread pools depending on its size */
- if (g_strv_length (request->uris) > threshold_scheduler->threshold)
- g_thread_pool_push (threshold_scheduler->large_pool, request, NULL);
- else
- g_thread_pool_push (threshold_scheduler->small_pool, request, NULL);
+ /* enqueue the request in the pool */
+ g_thread_pool_push (lifo_scheduler->pool, request, NULL);
- g_mutex_unlock (threshold_scheduler->mutex);
+ g_mutex_unlock (lifo_scheduler->mutex);
}
static void
-tumbler_threshold_scheduler_unqueue (TumblerScheduler *scheduler,
- guint handle)
+tumbler_lifo_scheduler_unqueue (TumblerScheduler *scheduler,
+ guint handle)
{
- TumblerThresholdScheduler *threshold_scheduler =
- TUMBLER_THRESHOLD_SCHEDULER (scheduler);
+ TumblerLifoScheduler *lifo_scheduler =
+ TUMBLER_LIFO_SCHEDULER (scheduler);
- g_return_if_fail (TUMBLER_IS_THRESHOLD_SCHEDULER (scheduler));
+ g_return_if_fail (TUMBLER_IS_LIFO_SCHEDULER (scheduler));
g_return_if_fail (handle != 0);
- g_mutex_lock (threshold_scheduler->mutex);
+ g_mutex_lock (lifo_scheduler->mutex);
- g_list_foreach (threshold_scheduler->requests,
- (GFunc) tumbler_threshold_scheduler_unqueue_request,
+ g_list_foreach (lifo_scheduler->requests,
+ (GFunc) tumbler_lifo_scheduler_unqueue_request,
GUINT_TO_POINTER (handle));
- g_mutex_unlock (threshold_scheduler->mutex);
+ g_mutex_unlock (lifo_scheduler->mutex);
}
static void
-tumbler_threshold_scheduler_finish_request (TumblerThresholdScheduler *scheduler,
- TumblerSchedulerRequest *request)
+tumbler_lifo_scheduler_finish_request (TumblerLifoScheduler *scheduler,
+ TumblerSchedulerRequest *request)
{
- g_return_if_fail (TUMBLER_IS_THRESHOLD_SCHEDULER (scheduler));
+ g_return_if_fail (TUMBLER_IS_LIFO_SCHEDULER (scheduler));
g_return_if_fail (request != NULL);
g_signal_emit_by_name (scheduler, "finished", request->handle);
scheduler->requests = g_list_remove (scheduler->requests,
- request);
+ request);
tumbler_scheduler_request_free (request);
}
@@ -295,8 +287,8 @@ tumbler_threshold_scheduler_finish_request (TumblerThresholdScheduler *scheduler
static void
-tumbler_threshold_scheduler_unqueue_request (TumblerSchedulerRequest *request,
- gpointer user_data)
+tumbler_lifo_scheduler_unqueue_request (TumblerSchedulerRequest *request,
+ gpointer user_data)
{
guint handle = GPOINTER_TO_UINT (user_data);
@@ -310,10 +302,10 @@ tumbler_threshold_scheduler_unqueue_request (TumblerSchedulerRequest *request,
static void
-tumbler_threshold_scheduler_thread (gpointer data,
- gpointer user_data)
+tumbler_lifo_scheduler_thread (gpointer data,
+ gpointer user_data)
{
- TumblerThresholdScheduler *scheduler = user_data;
+ TumblerLifoScheduler *scheduler = user_data;
TumblerSchedulerRequest *request = data;
TumblerFileInfo *info;
const gchar **uris;
@@ -327,7 +319,7 @@ tumbler_threshold_scheduler_thread (gpointer data,
GList *lp;
gint n;
- g_return_if_fail (TUMBLER_IS_THRESHOLD_SCHEDULER (scheduler));
+ g_return_if_fail (TUMBLER_IS_LIFO_SCHEDULER (scheduler));
g_return_if_fail (request != NULL);
/* notify others that we're starting to process this request */
@@ -338,7 +330,7 @@ tumbler_threshold_scheduler_thread (gpointer data,
if (request->unqueued)
{
g_mutex_lock (scheduler->mutex);
- tumbler_threshold_scheduler_finish_request (scheduler, request);
+ tumbler_lifo_scheduler_finish_request (scheduler, request);
g_mutex_unlock (scheduler->mutex);
return;
}
@@ -350,7 +342,7 @@ tumbler_threshold_scheduler_thread (gpointer data,
if (request->unqueued)
{
g_mutex_lock (scheduler->mutex);
- tumbler_threshold_scheduler_finish_request (scheduler, request);
+ tumbler_lifo_scheduler_finish_request (scheduler, request);
g_mutex_unlock (scheduler->mutex);
return;
}
@@ -435,19 +427,23 @@ tumbler_threshold_scheduler_thread (gpointer data,
if (request->unqueued)
{
g_mutex_lock (scheduler->mutex);
- tumbler_threshold_scheduler_finish_request (scheduler, request);
+ tumbler_lifo_scheduler_finish_request (scheduler, request);
g_mutex_unlock (scheduler->mutex);
return;
}
+ /* We immediately forward error and ready so that clients rapidly know
+ * when individual thumbnails are ready. It's a LIFO for better inter-
+ * activity with the clients, so we assume this behaviour to be wanted. */
+
/* connect to the error signal of the thumbnailer */
g_signal_connect (request->thumbnailers[n], "error",
- G_CALLBACK (tumbler_threshold_scheduler_thumbnailer_error),
+ G_CALLBACK (tumbler_lifo_scheduler_thumbnailer_error),
request);
/* connect to the ready signal of the thumbnailer */
g_signal_connect (request->thumbnailers[n], "ready",
- G_CALLBACK (tumbler_threshold_scheduler_thumbnailer_ready),
+ G_CALLBACK (tumbler_lifo_scheduler_thumbnailer_ready),
request);
/* tell the thumbnailer to generate the thumbnail */
@@ -463,7 +459,7 @@ tumbler_threshold_scheduler_thread (gpointer data,
g_mutex_lock (scheduler->mutex);
/* notify others that we're finished processing the request */
- tumbler_threshold_scheduler_finish_request (scheduler, request);
+ tumbler_lifo_scheduler_finish_request (scheduler, request);
g_mutex_unlock (scheduler->mutex);
}
@@ -471,18 +467,18 @@ tumbler_threshold_scheduler_thread (gpointer data,
static void
-tumbler_threshold_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer,
- const gchar *failed_uri,
- gint error_code,
- const gchar *message,
- TumblerSchedulerRequest *request)
+tumbler_lifo_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnailer,
+ const gchar *failed_uri,
+ gint error_code,
+ const gchar *message,
+ TumblerSchedulerRequest *request)
{
const gchar *failed_uris[] = { failed_uri, NULL };
g_return_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer));
g_return_if_fail (failed_uri != NULL);
g_return_if_fail (request != NULL);
- g_return_if_fail (TUMBLER_IS_THRESHOLD_SCHEDULER (request->scheduler));
+ g_return_if_fail (TUMBLER_IS_LIFO_SCHEDULER (request->scheduler));
/* forward the error signal */
g_signal_emit_by_name (request->scheduler, "error", request->handle, failed_uris,
@@ -492,16 +488,16 @@ tumbler_threshold_scheduler_thumbnailer_error (TumblerThumbnailer *thumbnai
static void
-tumbler_threshold_scheduler_thumbnailer_ready (TumblerThumbnailer *thumbnailer,
- const gchar *uri,
- TumblerSchedulerRequest *request)
+tumbler_lifo_scheduler_thumbnailer_ready (TumblerThumbnailer *thumbnailer,
+ const gchar *uri,
+ TumblerSchedulerRequest *request)
{
const gchar *uris[] = { uri, NULL };
g_return_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer));
g_return_if_fail (uri != NULL);
g_return_if_fail (request != NULL);
- g_return_if_fail (TUMBLER_IS_THRESHOLD_SCHEDULER (request->scheduler));
+ g_return_if_fail (TUMBLER_IS_LIFO_SCHEDULER (request->scheduler));
/* forward the ready signal */
g_signal_emit_by_name (request->scheduler, "ready", uris);
@@ -510,7 +506,7 @@ tumbler_threshold_scheduler_thumbnailer_ready (TumblerThumbnailer *thumbnai
TumblerScheduler *
-tumbler_threshold_scheduler_new (void)
+tumbler_lifo_scheduler_new (const gchar *kind)
{
- return g_object_new (TUMBLER_TYPE_THRESHOLD_SCHEDULER, NULL);
+ return g_object_new (TUMBLER_TYPE_LIFO_SCHEDULER, "kind", kind, NULL);
}
diff --git a/tumblerd/tumbler-lifo-scheduler.h b/tumblerd/tumbler-lifo-scheduler.h
new file mode 100644
index 0000000..badf925
--- /dev/null
+++ b/tumblerd/tumbler-lifo-scheduler.h
@@ -0,0 +1,44 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TUMBLER_LIFO_SCHEDULER_H__
+#define __TUMBLER_LIFO_SCHEDULER_H__
+
+#include <tumblerd/tumbler-scheduler.h>
+
+G_BEGIN_DECLS;
+
+#define TUMBLER_TYPE_LIFO_SCHEDULER (tumbler_lifo_scheduler_get_type ())
+#define TUMBLER_LIFO_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUMBLER_TYPE_LIFO_SCHEDULER, TumblerLifoScheduler))
+#define TUMBLER_LIFO_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUMBLER_TYPE_LIFO_SCHEDULER, TumblerLifoSchedulerClass))
+#define TUMBLER_IS_LIFO_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUMBLER_TYPE_LIFO_SCHEDULER))
+#define TUMBLER_IS_LIFO_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUMBLER_TYPE_LIFO_SCHEDULER)
+#define TUMBLER_LIFO_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUMBLER_TYPE_LIFO_SCHEDULER, TumblerLifoSchedulerClass))
+
+typedef struct _TumblerLifoSchedulerClass TumblerLifoSchedulerClass;
+typedef struct _TumblerLifoScheduler TumblerLifoScheduler;
+
+GType tumbler_lifo_scheduler_get_type (void) G_GNUC_CONST;
+
+TumblerScheduler *tumbler_lifo_scheduler_new (const gchar *kind) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
+G_END_DECLS;
+
+#endif /* !__TUMBLER_LIFO_SCHEDULER_H__ */
diff --git a/tumblerd/tumbler-scheduler.c b/tumblerd/tumbler-scheduler.c
index 9b4ea7d..08b74c4 100644
--- a/tumblerd/tumbler-scheduler.c
+++ b/tumblerd/tumbler-scheduler.c
@@ -168,6 +168,15 @@ tumbler_scheduler_take_request (TumblerScheduler *scheduler,
}
+const gchar*
+tumbler_scheduler_get_kind (TumblerScheduler *scheduler)
+{
+ g_return_if_fail (TUMBLER_IS_SCHEDULER (scheduler));
+ g_return_if_fail (TUMBLER_SCHEDULER_GET_IFACE (scheduler)->get_kind != NULL);
+
+ TUMBLER_SCHEDULER_GET_IFACE (scheduler)->get_kind (scheduler);
+}
+
void
tumbler_scheduler_emit_uri_error (TumblerScheduler *scheduler,
diff --git a/tumblerd/tumbler-scheduler.h b/tumblerd/tumbler-scheduler.h
index 6f72a1d..d1614c0 100644
--- a/tumblerd/tumbler-scheduler.h
+++ b/tumblerd/tumbler-scheduler.h
@@ -57,6 +57,8 @@ struct _TumblerSchedulerIface
TumblerSchedulerRequest *request);
void (*unqueue) (TumblerScheduler *scheduler,
guint handle);
+ const gchar*
+ (*get_kind) (TumblerScheduler *scheduler);
};
GType tumbler_scheduler_get_type (void) G_GNUC_CONST;
@@ -65,6 +67,7 @@ void tumbler_scheduler_push (TumblerSchedul
TumblerSchedulerRequest *request);
void tumbler_scheduler_unqueue (TumblerScheduler *scheduler,
guint handle);
+const gchar* tumbler_scheduler_get_kind (TumblerScheduler *scheduler);
void tumbler_scheduler_take_request (TumblerScheduler *scheduler,
TumblerSchedulerRequest *request);
void tumbler_scheduler_emit_uri_error (TumblerScheduler *scheduler,
diff --git a/tumblerd/tumbler-service.c b/tumblerd/tumbler-service.c
index 794e5d9..25ffc3c 100644
--- a/tumblerd/tumbler-service.c
+++ b/tumblerd/tumbler-service.c
@@ -36,7 +36,7 @@
#include <tumblerd/tumbler-scheduler.h>
#include <tumblerd/tumbler-service.h>
#include <tumblerd/tumbler-service-dbus-bindings.h>
-#include <tumblerd/tumbler-threshold-scheduler.h>
+#include <tumblerd/tumbler-lifo-scheduler.h>
#include <tumblerd/tumbler-utils.h>
@@ -214,7 +214,7 @@ tumbler_service_constructed (GObject *object)
#if 0
service->scheduler = tumbler_naive_scheduler_new ();
#else
- service->scheduler = tumbler_threshold_scheduler_new ();
+ service->scheduler = tumbler_lifo_scheduler_new ("foreground");
#endif
g_signal_connect (service->scheduler, "error",
diff --git a/tumblerd/tumbler-threshold-scheduler.h b/tumblerd/tumbler-threshold-scheduler.h
deleted file mode 100644
index 07c4d13..0000000
--- a/tumblerd/tumbler-threshold-scheduler.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* vi:set et ai sw=2 sts=2 ts=2: */
-/*-
- * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __TUMBLER_THRESHOLD_SCHEDULER_H__
-#define __TUMBLER_THRESHOLD_SCHEDULER_H__
-
-#include <tumblerd/tumbler-scheduler.h>
-
-G_BEGIN_DECLS;
-
-#define TUMBLER_TYPE_THRESHOLD_SCHEDULER (tumbler_threshold_scheduler_get_type ())
-#define TUMBLER_THRESHOLD_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUMBLER_TYPE_THRESHOLD_SCHEDULER, TumblerThresholdScheduler))
-#define TUMBLER_THRESHOLD_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUMBLER_TYPE_THRESHOLD_SCHEDULER, TumblerThresholdSchedulerClass))
-#define TUMBLER_IS_THRESHOLD_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUMBLER_TYPE_THRESHOLD_SCHEDULER))
-#define TUMBLER_IS_THRESHOLD_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUMBLER_TYPE_THRESHOLD_SCHEDULER)
-#define TUMBLER_THRESHOLD_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUMBLER_TYPE_THRESHOLD_SCHEDULER, TumblerThresholdSchedulerClass))
-
-typedef struct _TumblerThresholdSchedulerClass TumblerThresholdSchedulerClass;
-typedef struct _TumblerThresholdScheduler TumblerThresholdScheduler;
-
-GType tumbler_threshold_scheduler_get_type (void) G_GNUC_CONST;
-
-TumblerScheduler *tumbler_threshold_scheduler_new (void) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-
-G_END_DECLS;
-
-#endif /* !__TUMBLER_THRESHOLD_SCHEDULER_H__ */
More information about the Xfce4-commits
mailing list