[gimp/metadata-browser] pixel-processor: fix GMutex related deprecation
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] pixel-processor: fix GMutex related deprecation
- Date: Thu, 13 Sep 2012 00:08:21 +0000 (UTC)
commit 3d482a98f1dab724cacba95e8ab5ffa4232ac0a2
Author: Michael Murà <mure michael gmail com>
Date: Sun May 6 21:03:02 2012 +0900
pixel-processor: fix GMutex related deprecation
app/base/pixel-processor.c | 39 +++++++++++++++++----------------------
1 files changed, 17 insertions(+), 22 deletions(-)
---
diff --git a/app/base/pixel-processor.c b/app/base/pixel-processor.c
index 43f5817..16047a2 100644
--- a/app/base/pixel-processor.c
+++ b/app/base/pixel-processor.c
@@ -40,7 +40,7 @@
static GThreadPool *pool = NULL;
-static GMutex *pool_mutex = NULL;
+static GMutex pool_mutex;
static GCond *pool_cond = NULL;
@@ -68,7 +68,7 @@ struct _PixelProcessor
gpointer data;
#ifdef ENABLE_MP
- GMutex *mutex;
+ GMutex mutex;
gint threads;
gboolean first;
#endif
@@ -88,7 +88,7 @@ do_parallel_regions (PixelProcessor *processor)
PixelRegion tr[4];
gint i;
- g_mutex_lock (processor->mutex);
+ g_mutex_lock (&processor->mutex);
/* the first thread getting here must not call pixel_regions_process() */
if (! processor->first && processor->PRI)
@@ -112,7 +112,7 @@ do_parallel_regions (PixelProcessor *processor)
}
}
- g_mutex_unlock (processor->mutex);
+ g_mutex_unlock (&processor->mutex);
switch (processor->num_regions)
{
@@ -148,7 +148,7 @@ do_parallel_regions (PixelProcessor *processor)
break;
}
- g_mutex_lock (processor->mutex);
+ g_mutex_lock (&processor->mutex);
for (i = 0; i < processor->num_regions; i++)
{
@@ -169,15 +169,15 @@ do_parallel_regions (PixelProcessor *processor)
if (processor->threads == 0)
{
- g_mutex_unlock (processor->mutex);
+ g_mutex_unlock (&processor->mutex);
- g_mutex_lock (pool_mutex);
+ g_mutex_lock (&pool_mutex);
g_cond_signal (pool_cond);
- g_mutex_unlock (pool_mutex);
+ g_mutex_unlock (&pool_mutex);
}
else
{
- g_mutex_unlock (processor->mutex);
+ g_mutex_unlock (&processor->mutex);
}
}
#endif
@@ -285,9 +285,9 @@ pixel_regions_do_parallel (PixelProcessor *processor,
processor->first = TRUE;
processor->threads = tasks;
- processor->mutex = g_mutex_new();
+ g_mutex_init (&processor->mutex);
- g_mutex_lock (pool_mutex);
+ g_mutex_lock (&pool_mutex);
while (tasks--)
{
@@ -311,11 +311,11 @@ pixel_regions_do_parallel (PixelProcessor *processor,
g_get_current_time (&timeout);
g_time_val_add (&timeout, PROGRESS_TIMEOUT * 1024);
- g_cond_timed_wait (pool_cond, pool_mutex, &timeout);
+ g_cond_timed_wait (pool_cond, &pool_mutex, &timeout);
- g_mutex_lock (processor->mutex);
+ g_mutex_lock (&processor->mutex);
progress = processor->progress;
- g_mutex_unlock (processor->mutex);
+ g_mutex_unlock (&processor->mutex);
progress_func (progress_data,
(gdouble) progress / (gdouble) pixels);
@@ -324,12 +324,10 @@ pixel_regions_do_parallel (PixelProcessor *processor,
else
{
while (processor->threads != 0)
- g_cond_wait (pool_cond, pool_mutex);
+ g_cond_wait (pool_cond, &pool_mutex);
}
- g_mutex_unlock (pool_mutex);
-
- g_mutex_free (processor->mutex);
+ g_mutex_unlock (&pool_mutex);
}
else
#endif
@@ -428,9 +426,6 @@ pixel_processor_set_num_threads (gint num_threads)
g_cond_free (pool_cond);
pool_cond = NULL;
-
- g_mutex_free (pool_mutex);
- pool_mutex = NULL;
}
}
else
@@ -446,7 +441,7 @@ pixel_processor_set_num_threads (gint num_threads)
pool = g_thread_pool_new ((GFunc) do_parallel_regions, NULL,
num_threads, TRUE, &error);
- pool_mutex = g_mutex_new ();
+ g_mutex_init (&pool_mutex);
pool_cond = g_cond_new ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]