[gegl] buffer: make more calls conditional of number of threads being > 1
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: make more calls conditional of number of threads being > 1
- Date: Fri, 11 Jul 2014 14:26:15 +0000 (UTC)
commit 95adb26c182535a23491d7e7062dde0cfa23fb0c
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Jul 11 15:44:16 2014 +0200
buffer: make more calls conditional of number of threads being > 1
gegl/buffer/gegl-buffer-access.c | 4 ++++
gegl/buffer/gegl-buffer.c | 15 +++++++++++----
gegl/buffer/gegl-sampler.c | 10 ++++++++--
3 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index a9c71d7..d188aff 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -113,6 +113,7 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
}
}
+ g_rec_mutex_lock (&buffer->tile_storage->mutex);
{
gint tile_width = buffer->tile_width;
gint tile_height = buffer->tile_height;
@@ -159,6 +160,7 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
}
}
}
+ g_rec_mutex_unlock (&buffer->tile_storage->mutex);
}
static inline void
@@ -177,6 +179,7 @@ __gegl_buffer_set_pixel (GeglBuffer *buffer,
x >= abyss->x + abyss->width)
return;
+ g_rec_mutex_lock (&buffer->tile_storage->mutex);
{
gint tile_width = buffer->tile_width;
gint tile_height = buffer->tile_height;
@@ -229,6 +232,7 @@ __gegl_buffer_set_pixel (GeglBuffer *buffer,
gegl_tile_unlock (tile);
}
}
+ g_rec_mutex_unlock (&buffer->tile_storage->mutex);
}
enum _GeglBufferSetFlag {
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index d3716b6..f6e78a8 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -1110,14 +1110,18 @@ gegl_buffer_try_lock (GeglBuffer *buffer)
{
GeglTileBackend *backend = gegl_buffer_backend (buffer);
- g_mutex_lock (&buffer->tile_storage->mutex);
+ gboolean threaded = gegl_config_threads ()>1;
+
+ if (threaded)
+ g_mutex_lock (&buffer->tile_storage->mutex);
if (buffer->lock_count > 0)
buffer->lock_count++;
else if (gegl_tile_backend_file_try_lock (GEGL_TILE_BACKEND_FILE (backend)))
buffer->lock_count++;
else
ret = FALSE;
- g_mutex_unlock (&buffer->tile_storage->mutex);
+ if (threaded)
+ g_mutex_unlock (&buffer->tile_storage->mutex);
}
return ret;
@@ -1142,9 +1146,11 @@ gegl_buffer_unlock (GeglBuffer *buffer)
if (gegl_buffer_is_shared (buffer))
{
+ gboolean threaded = gegl_config_threads ()>1;
GeglTileBackend *backend = gegl_buffer_backend (buffer);
- g_mutex_lock (&buffer->tile_storage->mutex);
+ if (threaded)
+ g_mutex_lock (&buffer->tile_storage->mutex);
buffer->lock_count--;
g_assert (buffer->lock_count >= 0);
@@ -1152,7 +1158,8 @@ gegl_buffer_unlock (GeglBuffer *buffer)
if (buffer->lock_count == 0)
ret = gegl_tile_backend_file_unlock (GEGL_TILE_BACKEND_FILE (backend));
- g_mutex_unlock (&buffer->tile_storage->mutex);
+ if (threaded)
+ g_mutex_unlock (&buffer->tile_storage->mutex);
}
return ret;
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index 0631df1..59788bf 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -37,6 +37,8 @@
#include "gegl-sampler-nohalo.h"
#include "gegl-sampler-lohalo.h"
+#include "gegl-config.h"
+
enum
{
PROP_0,
@@ -524,6 +526,8 @@ gegl_buffer_sample_at_level (GeglBuffer *buffer,
}*/
static GMutex mutex = {0,};
+ gboolean threaded = gegl_config_threads ()>1;
+
if (!format)
format = buffer->soft_format;
@@ -534,7 +538,8 @@ gegl_buffer_sample_at_level (GeglBuffer *buffer,
gegl_buffer_cl_cache_flush (buffer, &rect);
}
- g_mutex_lock (&mutex);
+ if (threaded)
+ g_mutex_lock (&mutex);
/* unset the cached sampler if it dosn't match the needs */
if (buffer->sampler != NULL &&
@@ -562,7 +567,8 @@ gegl_buffer_sample_at_level (GeglBuffer *buffer,
}
buffer->sampler->get(buffer->sampler, x, y, scale, dest, repeat_mode);
- g_mutex_unlock (&mutex);
+ if (threaded)
+ g_mutex_unlock (&mutex);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]