summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/dvi/dvi-document.c22
-rw-r--r--libdocument/ev-document.c34
-rw-r--r--libdocument/ev-mapping-list.c2
-rw-r--r--libview/ev-job-scheduler.c34
-rw-r--r--previewer/ev-previewer.c6
-rw-r--r--shell/ev-daemon.c2
-rw-r--r--shell/main.c6
-rw-r--r--thumbnailer/atril-thumbnailer.c12
8 files changed, 39 insertions, 79 deletions
diff --git a/backend/dvi/dvi-document.c b/backend/dvi/dvi-document.c
index c34de6e1..77065361 100644
--- a/backend/dvi/dvi-document.c
+++ b/backend/dvi/dvi-document.c
@@ -41,7 +41,7 @@
#endif
#include <stdlib.h>
-GMutex *dvi_context_mutex = NULL;
+GMutex dvi_context_mutex;
enum {
PROP_0,
@@ -98,12 +98,12 @@ dvi_document_load (EvDocument *document,
if (!filename)
return FALSE;
- g_mutex_lock (dvi_context_mutex);
+ g_mutex_lock (&dvi_context_mutex);
if (dvi_document->context)
mdvi_destroy_context (dvi_document->context);
dvi_document->context = mdvi_init_context(dvi_document->params, dvi_document->spec, filename);
- g_mutex_unlock (dvi_context_mutex);
+ g_mutex_unlock (&dvi_context_mutex);
g_free (filename);
if (!dvi_document->context) {
@@ -175,9 +175,9 @@ dvi_document_render (EvDocument *document,
* thread safe. The work to the future -
* let context render page independently
*/
- g_mutex_lock (dvi_context_mutex);
+ g_mutex_lock (&dvi_context_mutex);
- mdvi_setpage (dvi_document->context, rc->page->index);
+ mdvi_setpage (&dvi_document->context, rc->page->index);
mdvi_set_shrink (dvi_document->context,
(int)((dvi_document->params->hshrink - 1) / rc->scale) + 1,
@@ -198,7 +198,7 @@ dvi_document_render (EvDocument *document,
mdvi_cairo_device_render (dvi_document->context);
surface = mdvi_cairo_device_get_surface (&dvi_document->context->device);
- g_mutex_unlock (dvi_context_mutex);
+ g_mutex_unlock (&dvi_context_mutex);
rotated_surface = ev_document_misc_surface_rotate_and_scale (surface,
required_width,
@@ -214,12 +214,12 @@ dvi_document_finalize (GObject *object)
{
DviDocument *dvi_document = DVI_DOCUMENT(object);
- g_mutex_lock (dvi_context_mutex);
+ g_mutex_lock (&dvi_context_mutex);
if (dvi_document->context) {
mdvi_cairo_device_free (&dvi_document->context->device);
mdvi_destroy_context (dvi_document->context);
}
- g_mutex_unlock (dvi_context_mutex);
+ g_mutex_unlock (&dvi_context_mutex);
if (dvi_document->params)
g_free (dvi_document->params);
@@ -257,8 +257,6 @@ dvi_document_class_init (DviDocumentClass *klass)
mdvi_register_special ("Color", "color", NULL, dvi_document_do_color_special, 1);
mdvi_register_fonts ();
- dvi_context_mutex = g_mutex_new ();
-
ev_document_class->load = dvi_document_load;
ev_document_class->save = dvi_document_save;
ev_document_class->get_n_pages = dvi_document_get_n_pages;
@@ -301,7 +299,7 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
thumb_width = (gint) (dvi_document->base_width * rc->scale);
thumb_height = (gint) (dvi_document->base_height * rc->scale);
- g_mutex_lock (dvi_context_mutex);
+ g_mutex_lock (&dvi_context_mutex);
mdvi_setpage (dvi_document->context, rc->page->index);
@@ -325,7 +323,7 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
mdvi_cairo_device_set_scale (&dvi_document->context->device, rc->scale);
mdvi_cairo_device_render (dvi_document->context);
surface = mdvi_cairo_device_get_surface (&dvi_document->context->device);
- g_mutex_unlock (dvi_context_mutex);
+ g_mutex_unlock (&dvi_context_mutex);
pixbuf = ev_document_misc_pixbuf_from_surface (surface);
cairo_surface_destroy (surface);
diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c
index 667f89f1..fc45830d 100644
--- a/libdocument/ev-document.c
+++ b/libdocument/ev-document.c
@@ -69,8 +69,8 @@ static gchar *_ev_document_get_page_label (EvDocument *document,
static EvDocumentInfo *_ev_document_get_info (EvDocument *document);
static gboolean _ev_document_support_synctex (EvDocument *document);
-GMutex *ev_doc_mutex = NULL;
-GMutex *ev_fc_mutex = NULL;
+static GMutex ev_doc_mutex;
+static GMutex ev_fc_mutex;
G_DEFINE_ABSTRACT_TYPE (EvDocument, ev_document, G_TYPE_OBJECT)
@@ -160,58 +160,40 @@ ev_document_class_init (EvDocumentClass *klass)
g_object_class->finalize = ev_document_finalize;
}
-GMutex *
-ev_document_get_doc_mutex (void)
-{
- if (ev_doc_mutex == NULL) {
- ev_doc_mutex = g_mutex_new ();
- }
- return ev_doc_mutex;
-}
-
void
ev_document_doc_mutex_lock (void)
{
- g_mutex_lock (ev_document_get_doc_mutex ());
+ g_mutex_lock (&ev_doc_mutex);
}
void
ev_document_doc_mutex_unlock (void)
{
- g_mutex_unlock (ev_document_get_doc_mutex ());
+ g_mutex_unlock (&ev_doc_mutex);
}
gboolean
ev_document_doc_mutex_trylock (void)
{
- return g_mutex_trylock (ev_document_get_doc_mutex ());
-}
-
-GMutex *
-ev_document_get_fc_mutex (void)
-{
- if (ev_fc_mutex == NULL) {
- ev_fc_mutex = g_mutex_new ();
- }
- return ev_fc_mutex;
+ return g_mutex_trylock (&ev_doc_mutex);
}
void
ev_document_fc_mutex_lock (void)
{
- g_mutex_lock (ev_document_get_fc_mutex ());
+ g_mutex_lock (&ev_fc_mutex);
}
void
ev_document_fc_mutex_unlock (void)
{
- g_mutex_unlock (ev_document_get_fc_mutex ());
+ g_mutex_unlock (&ev_fc_mutex);
}
gboolean
ev_document_fc_mutex_trylock (void)
{
- return g_mutex_trylock (ev_document_get_fc_mutex ());
+ return g_mutex_trylock (&ev_fc_mutex);
}
/**
diff --git a/libdocument/ev-mapping-list.c b/libdocument/ev-mapping-list.c
index 6c670158..44628b09 100644
--- a/libdocument/ev-mapping-list.c
+++ b/libdocument/ev-mapping-list.c
@@ -136,7 +136,7 @@ ev_mapping_list_unref (EvMappingList *mapping_list)
g_return_if_fail (mapping_list != NULL);
g_return_if_fail (mapping_list->ref_count > 0);
- if (g_atomic_int_exchange_and_add (&mapping_list->ref_count, -1) - 1 == 0) {
+ if (g_atomic_int_add (&mapping_list->ref_count, -1) - 1 == 0) {
g_list_foreach (mapping_list->list,
(GFunc)mapping_list_free_foreach,
mapping_list->data_destroy_func);
diff --git a/libview/ev-job-scheduler.c b/libview/ev-job-scheduler.c
index 9d028b0a..4cb6864c 100644
--- a/libview/ev-job-scheduler.c
+++ b/libview/ev-job-scheduler.c
@@ -40,8 +40,8 @@ static GQueue queue_high = G_QUEUE_INIT;
static GQueue queue_low = G_QUEUE_INIT;
static GQueue queue_none = G_QUEUE_INIT;
-static GCond *job_queue_cond = NULL;
-static GMutex *job_queue_mutex = NULL;
+static GCond job_queue_cond;
+static GMutex job_queue_mutex;
static GQueue *job_queue[EV_JOB_N_PRIORITIES] = {
&queue_urgent,
&queue_high,
@@ -55,12 +55,12 @@ ev_job_queue_push (EvSchedulerJob *job,
{
ev_debug_message (DEBUG_JOBS, "%s priority %d", EV_GET_TYPE_NAME (job->job), priority);
- g_mutex_lock (job_queue_mutex);
+ g_mutex_lock (&job_queue_mutex);
g_queue_push_tail (job_queue[priority], job);
- g_cond_broadcast (job_queue_cond);
+ g_cond_broadcast (&job_queue_cond);
- g_mutex_unlock (job_queue_mutex);
+ g_mutex_unlock (&job_queue_mutex);
}
static EvSchedulerJob *
@@ -83,9 +83,7 @@ ev_job_queue_get_next_unlocked (void)
static gpointer
ev_job_scheduler_init (gpointer data)
{
- job_queue_cond = g_cond_new ();
- job_queue_mutex = g_mutex_new ();
- g_thread_create (ev_job_thread_proxy, NULL, FALSE, NULL);
+ g_thread_new ("EvJobScheduler", ev_job_thread_proxy, NULL);
return NULL;
}
@@ -152,7 +150,7 @@ ev_scheduler_thread_job_cancelled (EvSchedulerJob *job,
ev_debug_message (DEBUG_JOBS, "%s", EV_GET_TYPE_NAME (job->job));
- g_mutex_lock (job_queue_mutex);
+ g_mutex_lock (&job_queue_mutex);
/* If the job is not still running,
* remove it from the job queue and job list.
@@ -162,10 +160,10 @@ ev_scheduler_thread_job_cancelled (EvSchedulerJob *job,
list = g_queue_find (job_queue[job->priority], job);
if (list) {
g_queue_delete_link (job_queue[job->priority], list);
- g_mutex_unlock (job_queue_mutex);
+ g_mutex_unlock (&job_queue_mutex);
ev_scheduler_job_destroy (job);
} else {
- g_mutex_unlock (job_queue_mutex);
+ g_mutex_unlock (&job_queue_mutex);
}
}
@@ -201,14 +199,14 @@ ev_job_thread_proxy (gpointer data)
while (TRUE) {
EvSchedulerJob *job;
- g_mutex_lock (job_queue_mutex);
+ g_mutex_lock (&job_queue_mutex);
job = ev_job_queue_get_next_unlocked ();
if (!job) {
- g_cond_wait (job_queue_cond, job_queue_mutex);
- g_mutex_unlock (job_queue_mutex);
+ g_cond_wait (&job_queue_cond, &job_queue_mutex);
+ g_mutex_unlock (&job_queue_mutex);
continue;
}
- g_mutex_unlock (job_queue_mutex);
+ g_mutex_unlock (&job_queue_mutex);
ev_job_thread (job->job);
ev_scheduler_job_destroy (job);
@@ -288,7 +286,7 @@ ev_job_scheduler_update_job (EvJob *job,
if (need_resort) {
GList *list;
- g_mutex_lock (job_queue_mutex);
+ g_mutex_lock (&job_queue_mutex);
list = g_queue_find (job_queue[s_job->priority], s_job);
if (list) {
@@ -296,10 +294,10 @@ ev_job_scheduler_update_job (EvJob *job,
EV_GET_TYPE_NAME (job), s_job->priority, priority);
g_queue_delete_link (job_queue[s_job->priority], list);
g_queue_push_tail (job_queue[priority], s_job);
- g_cond_broadcast (job_queue_cond);
+ g_cond_broadcast (&job_queue_cond);
}
- g_mutex_unlock (job_queue_mutex);
+ g_mutex_unlock (&job_queue_mutex);
}
}
diff --git a/previewer/ev-previewer.c b/previewer/ev-previewer.c
index bcf1bc9f..b19fc08f 100644
--- a/previewer/ev-previewer.c
+++ b/previewer/ev-previewer.c
@@ -130,12 +130,6 @@ main (gint argc, gchar **argv)
}
#endif
-#if !GLIB_CHECK_VERSION (2, 32, 0)
- /* Init glib threads asap */
- if (!g_thread_supported ())
- g_thread_init (NULL);
-#endif
-
#ifdef ENABLE_NLS
/* Initialize the i18n stuff */
bindtextdomain (GETTEXT_PACKAGE, ev_get_locale_dir());
diff --git a/shell/ev-daemon.c b/shell/ev-daemon.c
index e9c2f0ae..c242e550 100644
--- a/shell/ev-daemon.c
+++ b/shell/ev-daemon.c
@@ -521,8 +521,6 @@ main (gint argc, gchar **argv)
g_set_prgname ("atril-daemon");
- g_type_init ();
-
loop = g_main_loop_new (NULL, FALSE);
pending_invocations = g_hash_table_new_full (g_str_hash,
diff --git a/shell/main.c b/shell/main.c
index 3164d3da..367e0977 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -260,12 +260,6 @@ main (int argc, char *argv[])
}
#endif
-#if !GLIB_CHECK_VERSION (2, 32, 0)
- /* Init glib threads asap */
- if (!g_thread_supported ())
- g_thread_init (NULL);
-#endif
-
#ifdef ENABLE_NLS
/* Initialize the i18n stuff */
bindtextdomain (GETTEXT_PACKAGE, ev_get_locale_dir());
diff --git a/thumbnailer/atril-thumbnailer.c b/thumbnailer/atril-thumbnailer.c
index e5c214a1..c3288595 100644
--- a/thumbnailer/atril-thumbnailer.c
+++ b/thumbnailer/atril-thumbnailer.c
@@ -83,7 +83,7 @@ static void
time_monitor_start (const char *input)
{
finished = FALSE;
- g_thread_create (time_monitor, (gpointer) input, FALSE, NULL);
+ g_thread_new ("EvThumbnailerTimer", time_monitor, (gpointer) input);
}
static void
@@ -293,11 +293,6 @@ main (int argc, char *argv[])
input = file_arguments[0];
output = file_arguments[1];
- g_type_init ();
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
if (!ev_init ())
return -1;
@@ -328,8 +323,9 @@ main (int argc, char *argv[])
data.output = output;
data.size = size;
- g_thread_create ((GThreadFunc) atril_thumbnail_pngenc_get_async,
- &data, FALSE, NULL);
+ g_thread_new ("EvThumbnailerAsyncRenderer",
+ (GThreadFunc) atril_thumbnail_pngenc_get_async,
+ &data);
gtk_main ();