[tracker/queue: 2/3] tracker-store: Use enum
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/queue: 2/3] tracker-store: Use enum
- Date: Wed, 7 Apr 2010 13:19:30 +0000 (UTC)
commit c2eaae555496a85d1c8c887d4800191c155138ce
Author: Jürg Billeter <j bitron ch>
Date: Wed Apr 7 14:36:56 2010 +0200
tracker-store: Use enum
src/tracker-store/tracker-store.c | 22 ++++++++++------------
src/tracker-store/tracker-store.h | 6 ++++++
2 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
index 9bf4c09..280f2e4 100644
--- a/src/tracker-store/tracker-store.c
+++ b/src/tracker-store/tracker-store.c
@@ -36,13 +36,11 @@
#define TRACKER_STORE_TRANSACTION_MAX 4000
-#define N_QUEUES 2
-
typedef struct {
gboolean have_handler, have_sync_handler;
gboolean batch_mode, start_log;
guint batch_count;
- GQueue *queues[N_QUEUES];
+ GQueue *queues[TRACKER_STORE_N_PRIORITIES];
guint handler, sync_handler;
} TrackerStorePrivate;
@@ -81,7 +79,7 @@ private_free (gpointer data)
TrackerStorePrivate *private = data;
gint i;
- for (i = 0; i < N_QUEUES; i++) {
+ for (i = 0; i < TRACKER_STORE_N_PRIORITIES; i++) {
g_queue_free (private->queues[i]);
}
g_free (private);
@@ -195,7 +193,7 @@ queue_idle_handler (gpointer user_data)
TrackerStoreTask *task = NULL;
gint i;
- for (i = 0; task == NULL && i < N_QUEUES; i++) {
+ for (i = 0; task == NULL && i < TRACKER_STORE_N_PRIORITIES; i++) {
queue = private->queues[i];
task = g_queue_peek_head (queue);
}
@@ -287,7 +285,7 @@ queue_idle_handler (gpointer user_data)
store_task_free (task);
/* return TRUE if at least one queue is not empty (to keep idle handler running) */
- for (i = 0; i < N_QUEUES; i++) {
+ for (i = 0; i < TRACKER_STORE_N_PRIORITIES; i++) {
if (!g_queue_is_empty (private->queues[i])) {
return TRUE;
}
@@ -312,7 +310,7 @@ tracker_store_init (void)
private = g_new0 (TrackerStorePrivate, 1);
- for (i = 0; i < N_QUEUES; i++) {
+ for (i = 0; i < TRACKER_STORE_N_PRIORITIES; i++) {
private->queues[i] = g_queue_new ();
}
@@ -374,7 +372,7 @@ tracker_store_queue_commit (TrackerStoreCommitCallback callback,
task->data.update.client_id = g_strdup (client_id);
task->data.update.query = NULL;
- g_queue_push_tail (private->queues[1], task);
+ g_queue_push_tail (private->queues[TRACKER_STORE_PRIORITY_LOW], task);
if (!private->have_handler) {
start_handler (private);
@@ -405,7 +403,7 @@ tracker_store_queue_sparql_update (const gchar *sparql,
task->destroy = destroy;
task->data.update.client_id = g_strdup (client_id);
- g_queue_push_tail (private->queues[1], task);
+ g_queue_push_tail (private->queues[TRACKER_STORE_PRIORITY_LOW], task);
if (!private->have_handler) {
start_handler (private);
@@ -433,7 +431,7 @@ tracker_store_queue_turtle_import (GFile *file,
task->callback.update_callback = callback;
task->destroy = destroy;
- g_queue_push_tail (private->queues[1], task);
+ g_queue_push_tail (private->queues[TRACKER_STORE_PRIORITY_LOW], task);
if (!private->have_handler) {
start_handler (private);
@@ -507,7 +505,7 @@ tracker_store_get_queue_size (void)
private = g_static_private_get (&private_key);
g_return_val_if_fail (private != NULL, 0);
- for (i = 0; i < N_QUEUES; i++) {
+ for (i = 0; i < TRACKER_STORE_N_PRIORITIES; i++) {
result += g_queue_get_length (private->queues[i]);
}
return result;
@@ -525,7 +523,7 @@ tracker_store_unreg_batches (const gchar *client_id)
private = g_static_private_get (&private_key);
g_return_if_fail (private != NULL);
- for (i = 0; i < N_QUEUES; i++) {
+ for (i = 0; i < TRACKER_STORE_N_PRIORITIES; i++) {
queue = private->queues[i];
list = queue->head;
diff --git a/src/tracker-store/tracker-store.h b/src/tracker-store/tracker-store.h
index aa6f12f..c74e965 100644
--- a/src/tracker-store/tracker-store.h
+++ b/src/tracker-store/tracker-store.h
@@ -29,6 +29,12 @@
G_BEGIN_DECLS
+typedef enum {
+ TRACKER_STORE_PRIORITY_HIGH,
+ TRACKER_STORE_PRIORITY_LOW,
+ TRACKER_STORE_N_PRIORITIES
+} TrackerStorePriority;
+
typedef void (* TrackerStoreSparqlUpdateCallback) (GError *error,
gpointer user_data);
typedef void (* TrackerStoreCommitCallback) (gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]