summaryrefslogtreecommitdiff
path: root/libcaja-private
diff options
context:
space:
mode:
Diffstat (limited to 'libcaja-private')
-rw-r--r--libcaja-private/caja-file-changes-queue.c65
-rw-r--r--libcaja-private/caja-file-operations.c13
-rw-r--r--libcaja-private/caja-icon-info.c12
-rw-r--r--libcaja-private/caja-search-engine-simple.c6
4 files changed, 21 insertions, 75 deletions
diff --git a/libcaja-private/caja-file-changes-queue.c b/libcaja-private/caja-file-changes-queue.c
index 8b60d63a..58f11ad4 100644
--- a/libcaja-private/caja-file-changes-queue.c
+++ b/libcaja-private/caja-file-changes-queue.c
@@ -25,14 +25,6 @@
#include "caja-directory-notify.h"
-#ifdef G_THREADS_ENABLED
-#define MUTEX_LOCK(a) if ((a) != NULL) g_mutex_lock (a)
-#define MUTEX_UNLOCK(a) if ((a) != NULL) g_mutex_unlock (a)
-#else
-#define MUTEX_LOCK(a)
-#define MUTEX_UNLOCK(a)
-#endif
-
typedef enum
{
CHANGE_FILE_INITIAL,
@@ -57,9 +49,7 @@ typedef struct
{
GList *head;
GList *tail;
-#ifdef G_THREADS_ENABLED
GMutex mutex;
-#endif
} CajaFileChangesQueue;
static CajaFileChangesQueue *
@@ -69,9 +59,8 @@ caja_file_changes_queue_new (void)
result = g_new0 (CajaFileChangesQueue, 1);
-#ifdef G_THREADS_ENABLED
g_mutex_init (&result->mutex);
-#endif
+
return result;
}
@@ -88,62 +77,18 @@ caja_file_changes_queue_get (void)
return file_changes_queue;
}
-#if 0 /* no public free call yet */
-
-static void
-caja_file_change_free (CajaFileChange *change)
-{
- if (change->from)
- {
- g_object_unref (change->from);
- }
- if (change->to)
- {
- g_object_unref (change->to);
- }
-}
-
-void
-caja_file_changes_queue_free (CajaFileChangesQueue *queue)
-{
- GList *p;
- if (queue == NULL)
- {
- return;
- }
-
-#ifdef G_THREADS_ENABLED
- /* if lock on a defunct mutex were defined (returning a failure)
- * we would lock here
- */
-#endif
-
- for (p = queue->head; p != NULL; p = p->next)
- {
- caja_file_change_free (p->data);
- }
- g_list_free (queue->head);
-
-#ifdef G_THREADS_ENABLED
- g_mutex_clear (&queue->mutex);
-#endif
- g_free (queue);
-}
-
-#endif /* no public free call yet */
-
static void
caja_file_changes_queue_add_common (CajaFileChangesQueue *queue,
CajaFileChange *new_item)
{
/* enqueue the new queue item while locking down the list */
- MUTEX_LOCK (&queue->mutex);
+ g_mutex_lock (&queue->mutex);
queue->head = g_list_prepend (queue->head, new_item);
if (queue->tail == NULL)
queue->tail = queue->head;
- MUTEX_UNLOCK (&queue->mutex);
+ g_mutex_unlock (&queue->mutex);
}
void
@@ -245,7 +190,7 @@ caja_file_changes_queue_get_change (CajaFileChangesQueue *queue)
g_assert (queue != NULL);
/* dequeue the tail item while locking down the list */
- MUTEX_LOCK (&queue->mutex);
+ g_mutex_lock (&queue->mutex);
if (queue->tail == NULL)
{
@@ -261,7 +206,7 @@ caja_file_changes_queue_get_change (CajaFileChangesQueue *queue)
queue->tail = new_tail;
}
- MUTEX_UNLOCK (&queue->mutex);
+ g_mutex_unlock (&queue->mutex);
return result;
}
diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c
index e310de1f..534b3b9f 100644
--- a/libcaja-private/caja-file-operations.c
+++ b/libcaja-private/caja-file-operations.c
@@ -176,8 +176,7 @@ typedef struct {
} TransferInfo;
#define SECONDS_NEEDED_FOR_RELIABLE_TRANSFER_RATE 15
-#define NSEC_PER_SEC 1000000000
-#define NSEC_PER_MSEC 1000000
+#define NSEC_PER_MICROSEC 1000
#define MAXIMUM_DISPLAYED_FILE_NAME_LENGTH 50
@@ -1405,12 +1404,12 @@ report_delete_progress (CommonJob *job,
int files_left;
double elapsed, transfer_rate;
int remaining_time;
- guint64 now;
+ gint64 now;
char *files_left_s;
- now = g_get_monotonic_time () * 1000;
+ now = g_get_monotonic_time ();
if (transfer_info->last_report_time != 0 &&
- ABS ((gint64)(transfer_info->last_report_time - now)) < 100 * NSEC_PER_MSEC) {
+ ABS ((gint64)(transfer_info->last_report_time - now)) < 100 * NSEC_PER_MICROSEC) {
return;
}
transfer_info->last_report_time = now;
@@ -2878,10 +2877,10 @@ report_copy_progress (CopyMoveJob *copy_job,
is_move = copy_job->is_move;
- now = g_get_monotonic_time () * 1000;
+ now = g_get_monotonic_time ();
if (transfer_info->last_report_time != 0 &&
- ABS ((gint64)(transfer_info->last_report_time - now)) < 100 * NSEC_PER_MSEC) {
+ ABS ((gint64)(transfer_info->last_report_time - now)) < 100 * NSEC_PER_MICROSEC) {
return;
}
transfer_info->last_report_time = now;
diff --git a/libcaja-private/caja-icon-info.c b/libcaja-private/caja-icon-info.c
index 0adbd90c..1a55ab47 100644
--- a/libcaja-private/caja-icon-info.c
+++ b/libcaja-private/caja-icon-info.c
@@ -31,7 +31,7 @@ struct _CajaIconInfo
GObject parent;
gboolean sole_owner;
- guint64 last_use_time;
+ gint64 last_use_time;
GdkPixbuf *pixbuf;
gboolean got_embedded_rect;
@@ -56,7 +56,7 @@ G_DEFINE_TYPE (CajaIconInfo,
static void
caja_icon_info_init (CajaIconInfo *icon)
{
- icon->last_use_time = g_get_monotonic_time () * 1000;
+ icon->last_use_time = g_get_monotonic_time ();
icon->sole_owner = TRUE;
}
@@ -79,7 +79,7 @@ pixbuf_toggle_notify (gpointer info,
g_object_remove_toggle_ref (object,
pixbuf_toggle_notify,
info);
- icon->last_use_time = g_get_monotonic_time () * 1000;
+ icon->last_use_time = g_get_monotonic_time ();
schedule_reap_cache ();
}
}
@@ -191,7 +191,7 @@ static GHashTable *loadable_icon_cache = NULL;
static GHashTable *themed_icon_cache = NULL;
static guint reap_cache_timeout = 0;
-#define NSEC_PER_SEC ((guint64)1000000000L)
+#define MICROSEC_PER_SEC ((guint64)1000000L)
static guint time_now;
@@ -205,7 +205,7 @@ reap_old_icon (gpointer key,
if (icon->sole_owner)
{
- if (time_now - icon->last_use_time > 30 * NSEC_PER_SEC)
+ if (time_now - icon->last_use_time > 30 * MICROSEC_PER_SEC)
{
/* This went unused 30 secs ago. reap */
return TRUE;
@@ -227,7 +227,7 @@ reap_cache (gpointer data)
reapable_icons_left = TRUE;
- time_now = g_get_monotonic_time () * 1000;
+ time_now = g_get_monotonic_time ();
if (loadable_icon_cache)
{
diff --git a/libcaja-private/caja-search-engine-simple.c b/libcaja-private/caja-search-engine-simple.c
index 8a768e50..e4078b36 100644
--- a/libcaja-private/caja-search-engine-simple.c
+++ b/libcaja-private/caja-search-engine-simple.c
@@ -367,6 +367,7 @@ caja_search_engine_simple_start (CajaSearchEngine *engine)
{
CajaSearchEngineSimple *simple;
SearchThreadData *data;
+ GThread *thread;
simple = CAJA_SEARCH_ENGINE_SIMPLE (engine);
@@ -382,9 +383,10 @@ caja_search_engine_simple_start (CajaSearchEngine *engine)
data = search_thread_data_new (simple, simple->details->query);
- g_thread_create (search_thread_func, data, FALSE, NULL);
-
+ thread = g_thread_new ("caja-search-simple", search_thread_func, data);
simple->details->active_search = data;
+
+ g_thread_unref (thread);
}
static void