[gegl] Enable multi threading by default.



commit faeac3ad3c41f181a0a6b156f0be3925f0486c72
Author: �yvind Kolås <pippin gimp org>
Date:   Mon Apr 5 17:41:15 2010 +0100

    Enable multi threading by default.
    
    Use of multiple threads is still experimental, but can be enabled by
    setting the environment variable GEGL_THREADS to the desired number
    of worker threads. (in GIMP it seems like the gegl tool sometimes work
    and the view has more severe issues).

 configure.ac                          |   13 -----------
 gegl/buffer/gegl-buffer-iterator.c    |   19 -----------------
 gegl/buffer/gegl-buffer-linear.c      |    4 ---
 gegl/buffer/gegl-buffer.c             |    4 ---
 gegl/buffer/gegl-cache.c              |   17 ---------------
 gegl/buffer/gegl-tile-handler-cache.c |   36 +--------------------------------
 gegl/buffer/gegl-tile-storage.c       |    4 ---
 gegl/buffer/gegl-tile-storage.h       |    2 -
 gegl/buffer/gegl-tile.c               |   12 -----------
 gegl/buffer/gegl-tile.h               |    2 -
 gegl/gegl-config.c                    |   14 +-----------
 gegl/gegl-config.h                    |    2 -
 gegl/gegl-init.c                      |    8 -------
 gegl/graph/gegl-node.c                |   28 +-----------------------
 gegl/graph/gegl-node.h                |    2 -
 gegl/operation/gegl-operation.c       |    4 ---
 gegl/process/gegl-have-visitor.c      |    4 ---
 gegl/process/gegl-prepare-visitor.c   |    8 -------
 18 files changed, 5 insertions(+), 178 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 58c28b1..4c1fe36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -185,19 +185,6 @@ else
   AC_MSG_RESULT([no])
 fi
 
-AC_MSG_CHECKING([whether to enable multi threading])
-AC_ARG_ENABLE(mt,
-              [  --enable-mt             turn on multi-threading (unstable, default=no)],
-)
-if eval "test x$enable_mt = xyes"; then
-    AC_DEFINE(ENABLE_MT, 1, [Defined to 1 if multi-threading is enabled.])
-    AC_MSG_RESULT([yes])
-    enable_mt="yes (WARNING: unstable)"
-else
-    enable_mt="no"
-    AC_MSG_RESULT([no])
-fi
-
 
 changequote(,)dnl
 if eval "test x$GCC = xyes"; then
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index b8dbbd0..86f01e7 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -312,16 +312,12 @@ typedef struct BufInfo {
 
 static GArray *buf_pool = NULL;
 
-#if ENABLE_MT
 static GStaticMutex pool_mutex = G_STATIC_MUTEX_INIT;
-#endif
 
 static gpointer iterator_buf_pool_get (gint size)
 {
   gint i;
-#if ENABLE_MT
   g_static_mutex_lock (&pool_mutex);
-#endif
 
   if (G_UNLIKELY (!buf_pool))
     {
@@ -333,9 +329,7 @@ static gpointer iterator_buf_pool_get (gint size)
       if (info->size >= size && info->used == 0)
         {
           info->used ++;
-#if ENABLE_MT
           g_static_mutex_unlock (&pool_mutex);
-#endif
           return info->buf;
         }
     }
@@ -344,9 +338,7 @@ static gpointer iterator_buf_pool_get (gint size)
     info.size = size;
     info.buf = gegl_malloc (size);
     g_array_append_val (buf_pool, info);
-#if ENABLE_MT
     g_static_mutex_unlock (&pool_mutex);
-#endif
     return info.buf;
   }
 }
@@ -354,25 +346,19 @@ static gpointer iterator_buf_pool_get (gint size)
 static void iterator_buf_pool_release (gpointer buf)
 {
   gint i;
-#if ENABLE_MT
   g_static_mutex_lock (&pool_mutex);
-#endif
   for (i=0; i<buf_pool->len; i++)
     {
       BufInfo *info = &g_array_index (buf_pool, BufInfo, i);
       if (info->buf == buf)
         {
           info->used --;
-#if ENABLE_MT
           g_static_mutex_unlock (&pool_mutex);
-#endif
           return;
         }
     }
   g_assert (0);
-#if ENABLE_MT
   g_static_mutex_unlock (&pool_mutex);
-#endif
 }
 
 static void ensure_buf (GeglBufferIterators *i, gint no)
@@ -392,7 +378,6 @@ gboolean gegl_buffer_iterator_next     (GeglBufferIterator *iterator)
     g_error ("%s called on finished buffer iterator", G_STRFUNC);
   if (i->iteration_no == 0)
     {
-#if ENABLE_MT
       for (no=0; no<i->iterators;no++)
         {
           gint j;
@@ -406,7 +391,6 @@ gboolean gegl_buffer_iterator_next     (GeglBufferIterator *iterator)
           if (!found)
             gegl_buffer_lock (i->buffer[no]);
         }
-#endif
     }
   else
     {
@@ -515,8 +499,6 @@ gboolean gegl_buffer_iterator_next     (GeglBufferIterator *iterator)
 
   if (result == FALSE)
     {
-
-#if ENABLE_MT
       for (no=0; no<i->iterators;no++)
         {
           gint j;
@@ -530,7 +512,6 @@ gboolean gegl_buffer_iterator_next     (GeglBufferIterator *iterator)
           if (!found)
             gegl_buffer_unlock (i->buffer[no]);
         }
-#endif
 
       for (no=0; no<i->iterators;no++)
         {
diff --git a/gegl/buffer/gegl-buffer-linear.c b/gegl/buffer/gegl-buffer-linear.c
index 0626359..4c6f110 100644
--- a/gegl/buffer/gegl-buffer-linear.c
+++ b/gegl/buffer/gegl-buffer-linear.c
@@ -133,9 +133,7 @@ gegl_buffer_linear_open (GeglBuffer          *buffer,
     extent=&buffer->extent;
 
   /*gegl_buffer_lock (buffer);*/
-#if ENABLE_MT
   g_mutex_lock (buffer->tile_storage->mutex);
-#endif
   if (extent->x     == buffer->extent.x &&
       extent->y     == buffer->extent.y &&
       extent->width == buffer->tile_width &&
@@ -262,8 +260,6 @@ gegl_buffer_linear_close (GeglBuffer *buffer,
       g_object_set_data (G_OBJECT (buffer), "linear-buffers", linear_buffers);
     }
   /*gegl_buffer_unlock (buffer);*/
-#if ENABLE_MT
   g_mutex_unlock (buffer->tile_storage->mutex);
-#endif
   return;
 }
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index b545ee3..3c581ec 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -1145,9 +1145,7 @@ gegl_buffer_void (GeglBuffer *buffer)
   gint tile_height = buffer->tile_storage->tile_height;
   gint bufy        = 0;
 
-#if ENABLE_MT
   g_mutex_lock (buffer->tile_storage->mutex);
-#endif
   {
     gint z;
     gint factor = 1;
@@ -1191,9 +1189,7 @@ done_with_row:
         factor *= 2;
       }
   }
-#if ENABLE_MT
   g_mutex_unlock (buffer->tile_storage->mutex);
-#endif
 }
 
 
diff --git a/gegl/buffer/gegl-cache.c b/gegl/buffer/gegl-cache.c
index 4b4be21..0cf29b3 100644
--- a/gegl/buffer/gegl-cache.c
+++ b/gegl/buffer/gegl-cache.c
@@ -33,11 +33,6 @@
 #include "gegl-cache.h"
 #include "gegl-region.h"
 
-#undef ENABLE_MT
-#if ENABLE_MT
-static GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT;
-#endif
-
 enum
 {
   PROP_0,
@@ -371,9 +366,6 @@ void
 gegl_cache_invalidate (GeglCache           *self,
                        const GeglRectangle *roi)
 {
-#if ENABLE_MT
-  g_static_rec_mutex_lock (&mutex);
-#endif
 #if 0
   if (roi)
     {
@@ -406,9 +398,6 @@ gegl_cache_invalidate (GeglCache           *self,
       g_signal_emit (self, gegl_cache_signals[INVALIDATED], 0,
                      &rect, NULL);
     }
-#if ENABLE_MT
-  g_static_rec_mutex_unlock (&mutex);
-#endif
 }
 
 void
@@ -418,12 +407,6 @@ gegl_cache_computed (GeglCache           *self,
   g_return_if_fail (GEGL_IS_CACHE (self));
   g_return_if_fail (rect != NULL);
 
-#if ENABLE_MT
-  g_static_rec_mutex_lock (&mutex);
-#endif
   gegl_region_union_with_rect (self->valid_region, rect);
   g_signal_emit (self, gegl_cache_signals[COMPUTED], 0, rect, NULL);
-#if ENABLE_MT
-  g_static_rec_mutex_unlock (&mutex);
-#endif
 }
diff --git a/gegl/buffer/gegl-tile-handler-cache.c b/gegl/buffer/gegl-tile-handler-cache.c
index 8e99db3..c784319 100644
--- a/gegl/buffer/gegl-tile-handler-cache.c
+++ b/gegl/buffer/gegl-tile-handler-cache.c
@@ -30,9 +30,7 @@
 #include "gegl-tile-handler-cache.h"
 #include "gegl-debug.h"
 
-#if ENABLE_MT
 static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
-#endif
 
 struct _GeglTileHandlerCache
 {
@@ -178,9 +176,7 @@ dispose (GObject *object)
   CacheItem            *item;
   GSList               *iter;
 
-#ifdef ENABLE_MT
   g_static_mutex_lock (&mutex);
-#endif
   cache = GEGL_TILE_HANDLER_CACHE (object);
 
   /* only throw out items belonging to this cache instance */
@@ -201,9 +197,7 @@ dispose (GObject *object)
     }
   g_slist_free (cache->free_list);
   cache->free_list = NULL;
-#ifdef ENABLE_MT
   g_static_mutex_unlock (&mutex);
-#endif
 
   G_OBJECT_CLASS (gegl_tile_handler_cache_parent_class)->dispose (object);
 }
@@ -370,22 +364,16 @@ gegl_tile_handler_cache_get_tile (GeglTileHandlerCache *cache,
   pin.z = z;
   pin.handler = cache;
 
-#ifdef ENABLE_MT
   g_static_mutex_lock (&mutex);
-#endif
   result = g_hash_table_lookup (cache_ht, &pin);
   if (result)
     {
       g_queue_remove (cache_queue, result);
       g_queue_push_head (cache_queue, result);
-#ifdef ENABLE_MT
       g_static_mutex_unlock (&mutex);
-#endif
       return gegl_tile_ref (result->tile);
     }
-#ifdef ENABLE_MT
   g_static_mutex_unlock (&mutex);
-#endif
   return NULL;
 }
 
@@ -411,9 +399,7 @@ gegl_tile_handler_cache_trim (GeglTileHandlerCache *cache)
 {
   CacheItem *last_writable;
  
-#ifdef ENABLE_MT
   g_static_mutex_lock (&mutex);
-#endif
   last_writable = g_queue_pop_tail (cache_queue);
 
   if (last_writable != NULL)
@@ -422,14 +408,10 @@ gegl_tile_handler_cache_trim (GeglTileHandlerCache *cache)
       cache_total  -= last_writable->tile->size;
       gegl_tile_unref (last_writable->tile);
       g_slice_free (CacheItem, last_writable);
-#ifdef ENABLE_MT
       g_static_mutex_unlock (&mutex);
-#endif
       return TRUE;
     }
-#ifdef ENABLE_MT
-      g_static_mutex_unlock (&mutex);
-#endif
+  g_static_mutex_unlock (&mutex);
 
   return FALSE;
 }
@@ -442,9 +424,7 @@ gegl_tile_handler_cache_invalidate (GeglTileHandlerCache *cache,
 {
   GList *link;
 
-#ifdef ENABLE_MT
   g_static_mutex_lock (&mutex);
-#endif
   for (link = g_queue_peek_head_link (cache_queue); link; link = link->next)
     {
       CacheItem *item = link->data;
@@ -463,15 +443,11 @@ gegl_tile_handler_cache_invalidate (GeglTileHandlerCache *cache,
           g_hash_table_remove (cache_ht, item);
           g_slice_free (CacheItem, item);
           g_queue_delete_link (cache_queue, link);
-#ifdef ENABLE_MT
           g_static_mutex_unlock (&mutex);
-#endif
           return;
         }
     }
-#ifdef ENABLE_MT
   g_static_mutex_unlock (&mutex);
-#endif
 }
 
 
@@ -486,9 +462,7 @@ gegl_tile_handler_cache_void (GeglTileHandlerCache *cache,
   if (!cache_queue)
     return;
 
-#ifdef ENABLE_MT
   g_static_mutex_lock (&mutex);
-#endif
   for (link = g_queue_peek_head_link (cache_queue); link; link = link->next)
     {
       CacheItem *item = link->data;
@@ -506,15 +480,11 @@ gegl_tile_handler_cache_void (GeglTileHandlerCache *cache,
           g_hash_table_remove (cache_ht, item);
           g_slice_free (CacheItem, item);
           g_queue_delete_link (cache_queue, link);
-#ifdef ENABLE_MT
           g_static_mutex_unlock (&mutex);
-#endif
           return;
         }
     }
-#ifdef ENABLE_MT
   g_static_mutex_unlock (&mutex);
-#endif
 }
 
 void
@@ -532,9 +502,7 @@ gegl_tile_handler_cache_insert (GeglTileHandlerCache *cache,
   item->y       = y;
   item->z       = z;
 
-#if ENABLE_MT
   g_static_mutex_lock (&mutex);
-#endif
   cache_total  += item->tile->size;
   g_queue_push_head (cache_queue, item);
 
@@ -546,7 +514,5 @@ gegl_tile_handler_cache_insert (GeglTileHandlerCache *cache,
       GEGL_NOTE(GEGL_DEBUG_CACHE, "%f%% hit:%i miss:%i  %i]", cache_hits*100.0/(cache_hits+cache_misses), cache_hits, cache_misses, g_queue_get_length (cache_queue));*/
       gegl_tile_handler_cache_trim (cache);
     }
-#if ENABLE_MT
   g_static_mutex_unlock (&mutex);
-#endif
 }
diff --git a/gegl/buffer/gegl-tile-storage.c b/gegl/buffer/gegl-tile-storage.c
index 6786ea3..badb283 100644
--- a/gegl/buffer/gegl-tile-storage.c
+++ b/gegl/buffer/gegl-tile-storage.c
@@ -273,9 +273,7 @@ gegl_tile_storage_constructor (GType                  type,
                                               tile_storage,
                                               NULL);
   tile_storage->seen_zoom = FALSE;
-#if ENABLE_MT
   tile_storage->mutex = g_mutex_new ();
-#endif
 
   return object;
 }
@@ -290,9 +288,7 @@ gegl_tile_storage_finalize (GObject *object)
 
   if (self->path)
     g_free (self->path);
-#if ENABLE_MT
   g_mutex_free (self->mutex);
-#endif
 
   (*G_OBJECT_CLASS (parent_class)->finalize)(object);
 }
diff --git a/gegl/buffer/gegl-tile-storage.h b/gegl/buffer/gegl-tile-storage.h
index 1020d5b..887ee26 100644
--- a/gegl/buffer/gegl-tile-storage.h
+++ b/gegl/buffer/gegl-tile-storage.h
@@ -31,9 +31,7 @@
 struct _GeglTileStorage
 {
   GeglTileHandlerChain parent_instance;
-#if ENABLE_MT
   GMutex      *mutex;
-#endif
   Babl        *format;
   gint         tile_width;
   gint         tile_height;
diff --git a/gegl/buffer/gegl-tile.c b/gegl/buffer/gegl-tile.c
index 2381c9a..f07cf53 100644
--- a/gegl/buffer/gegl-tile.c
+++ b/gegl/buffer/gegl-tile.c
@@ -72,13 +72,11 @@ void gegl_tile_unref (GeglTile *tile)
         }
     }
 
-#if ENABLE_MT
   if (tile->mutex)
     {
       g_mutex_free (tile->mutex);
       tile->mutex = NULL;
     }
-#endif
   g_slice_free (GeglTile, tile);
 }
 
@@ -96,9 +94,7 @@ gegl_tile_new_bare (void)
   tile->next_shared = tile;
   tile->prev_shared = tile;
 
-#if ENABLE_MT
   tile->mutex = g_mutex_new ();
-#endif
   tile->destroy_notify = default_free;
 
   return tile;
@@ -118,19 +114,15 @@ gegl_tile_dup (GeglTile *src)
   tile->next_shared              = src->next_shared;
   src->next_shared               = tile;
   tile->prev_shared              = src;
-#if ENABLE_MT
   if (tile->next_shared != src)
     {
       g_mutex_lock (tile->next_shared->mutex);
     }
-#endif
   tile->next_shared->prev_shared = tile;
-#if ENABLE_MT
   if (tile->next_shared != src)
     {
       g_mutex_unlock (tile->next_shared->mutex);
     }
-#endif
 
   return tile;
 }
@@ -181,9 +173,7 @@ void gegl_bt (void);
 void
 gegl_tile_lock (GeglTile *tile)
 {
-#if ENABLE_MT
   g_mutex_lock (tile->mutex);
-#endif
 
   if (tile->lock != 0)
     {
@@ -245,9 +235,7 @@ gegl_tile_unlock (GeglTile *tile)
     }
   if (tile->lock==0)
     tile->rev++;
-#if ENABLE_MT
   g_mutex_unlock (tile->mutex);
-#endif
 }
 
 
diff --git a/gegl/buffer/gegl-tile.h b/gegl/buffer/gegl-tile.h
index 403652b..30cf69c 100644
--- a/gegl/buffer/gegl-tile.h
+++ b/gegl/buffer/gegl-tile.h
@@ -49,9 +49,7 @@ struct _GeglTile
   gchar            lock;        /* number of times the tile is write locked
                                  * should in theory just have the values 0/1
                                  */
-#if ENABLE_MT
   GMutex          *mutex;
-#endif
 
   /* the shared list is a doubly linked circular list */
   GeglTile        *next_shared;
diff --git a/gegl/gegl-config.c b/gegl/gegl-config.c
index 6073ef1..8c614eb 100644
--- a/gegl/gegl-config.c
+++ b/gegl/gegl-config.c
@@ -37,10 +37,8 @@ enum
   PROP_SWAP,
   PROP_BABL_TOLERANCE,
   PROP_TILE_WIDTH,
-  PROP_TILE_HEIGHT
-#if ENABLE_MT
-  ,PROP_THREADS
-#endif
+  PROP_TILE_HEIGHT,
+  PROP_THREADS
 };
 
 static void
@@ -81,11 +79,9 @@ get_property (GObject    *gobject,
         g_value_set_string (value, config->swap);
         break;
 
-#if ENABLE_MT
       case PROP_THREADS:
         g_value_set_int (value, config->threads);
         break;
-#endif
 
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
@@ -135,11 +131,9 @@ set_property (GObject      *gobject,
          g_free (config->swap);
         config->swap = g_value_dup_string (value);
         break;
-#if ENABLE_MT
       case PROP_THREADS:
         config->threads = g_value_get_int (value);
         return;
-#endif
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
         break;
@@ -205,12 +199,10 @@ gegl_config_class_init (GeglConfigClass *klass)
                                    g_param_spec_string ("swap", "Swap", "where gegl stores it's swap files", NULL,
                                                      G_PARAM_READWRITE));
 
-#if ENABLE_MT
   g_object_class_install_property (gobject_class, PROP_THREADS,
                                    g_param_spec_int ("threads", "Number of concurrent evaluation threads", "default tile height for created buffers.",
                                                      0, 16, 1,
                                                      G_PARAM_READWRITE));
-#endif
 }
 
 static void
@@ -222,7 +214,5 @@ gegl_config_init (GeglConfig *self)
   self->chunk_size  = 512 * 512;
   self->tile_width  = 128;
   self->tile_height = 64;
-#if ENABLE_MT
   self->threads = 1;
-#endif
 }
diff --git a/gegl/gegl-config.h b/gegl/gegl-config.h
index f7bbd46..3847aad 100644
--- a/gegl/gegl-config.h
+++ b/gegl/gegl-config.h
@@ -44,9 +44,7 @@ struct _GeglConfig
   gdouble  babl_tolerance;
   gint     tile_width;
   gint     tile_height;
-#if ENABLE_MT
   gint     threads;
-#endif
 };
 
 struct _GeglConfigClass
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index 675e5f0..93a34f4 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -205,9 +205,7 @@ static gchar   *cmd_gegl_chunk_size=NULL;
 static gchar   *cmd_gegl_quality=NULL;
 static gchar   *cmd_gegl_tile_size=NULL;
 static gchar   *cmd_babl_tolerance =NULL;
-#if ENABLE_MT
 static gchar   *cmd_gegl_threads=NULL;
-#endif
 
 static const GOptionEntry cmd_entries[]=
 {
@@ -241,13 +239,11 @@ static const GOptionEntry cmd_entries[]=
      G_OPTION_ARG_STRING, &cmd_gegl_quality,
      N_("The quality of rendering a value between 0.0(fast) and 1.0(reference)"), "<quality>"
     },
-#if ENABLE_MT
     {
      "gegl-threads", 0, 0,
      G_OPTION_ARG_STRING, &cmd_gegl_threads,
      N_("The number of concurrent processing threads to use."), "<threads>"
     },
-#endif
     { NULL }
 };
 
@@ -294,10 +290,8 @@ GeglConfig *gegl_config (void)
           if (str)
             config->tile_height = atoi(str+1);
         }
-#if ENABLE_MT
       if (g_getenv ("GEGL_THREADS"))
         config->threads = atoi(g_getenv("GEGL_THREADS"));
-#endif
       if (gegl_swap_dir())
         config->swap = g_strdup(gegl_swap_dir ());
     }
@@ -488,10 +482,8 @@ gegl_post_parse_hook (GOptionContext *context,
       if (str)
         config->tile_height = atoi(str+1);
     }
-#if ENABLE_MT
   if (cmd_gegl_threads)
     config->threads = atoi (cmd_gegl_threads);
-#endif
   if (cmd_babl_tolerance)
     g_object_set (config, "babl-tolerance", atof(cmd_babl_tolerance), NULL);
 
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index 32de4c8..a3fc8c5 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -200,9 +200,7 @@ gegl_node_init (GeglNode *self)
   self->operation      = NULL;
   self->is_graph       = FALSE;
   self->cache          = NULL;
-#if ENABLE_MT
   self->mutex          = g_mutex_new ();
-#endif
 
 }
 
@@ -282,9 +280,7 @@ gegl_node_finalize (GObject *gobject)
       g_free (self->priv->name);
     }
   g_hash_table_destroy (self->priv->contexts);
-#if ENABLE_MT
   g_mutex_free (self->mutex);
-#endif
 
   G_OBJECT_CLASS (gegl_node_parent_class)->finalize (gobject);
 }
@@ -864,7 +860,6 @@ gegl_node_apply_roi (GeglNode            *self,
 }
 
 
-#if ENABLE_MT
 typedef struct ThreadData
 {
   GeglNode      *node;
@@ -908,7 +903,6 @@ static void spawnrender (gpointer data,
     }
   g_mutex_unlock (mutex);
 }
-#endif
 
 
 void
@@ -920,13 +914,11 @@ gegl_node_blit (GeglNode            *self,
                 gint                 rowstride,
                 GeglBlitFlags        flags)
 {
-#if ENABLE_MT
   gint threads;
-#endif
   g_return_if_fail (GEGL_IS_NODE (self));
   g_return_if_fail (roi != NULL);
 
-#if ENABLE_MT
+#if 1
   threads = gegl_config ()->threads;
   if (threads > MAX_THREADS)
     threads = 0;
@@ -1024,7 +1016,7 @@ gegl_node_blit (GeglNode            *self,
           g_mutex_unlock (mutex);
         }
     }
-#else
+#else  /* thread free version, can be removed */
     if (flags == GEGL_BLIT_DEFAULT)
     {
       GeglBuffer *buffer;
@@ -1802,14 +1794,10 @@ gegl_node_get_context (GeglNode *self,
                        gpointer  context_id)
 {
   GeglOperationContext *context = NULL;
-#if ENABLE_MT
   g_mutex_lock (self->mutex);
-#endif
 
   context = g_hash_table_lookup (self->priv->contexts, context_id);
-#if ENABLE_MT
   g_mutex_unlock (self->mutex);
-#endif
   return context;
 }
 
@@ -1823,23 +1811,17 @@ gegl_node_remove_context (GeglNode *self,
   g_return_if_fail (context_id != NULL);
 
   context = gegl_node_get_context (self, context_id);
-#if ENABLE_MT
   g_mutex_lock (self->mutex);
-#endif
   if (!context)
     {
       g_warning ("didn't find context %p for %s",
                  context_id, gegl_node_get_debug_name (self));
-#if ENABLE_MT
       g_mutex_unlock (self->mutex);
-#endif
       return;
     }
   g_hash_table_remove (self->priv->contexts, context_id);
   gegl_operation_context_destroy (context);
-#if ENABLE_MT
   g_mutex_unlock (self->mutex);
-#endif
 }
 
 /* Creates, sets up and returns a new context for the node, or just returns it
@@ -1854,27 +1836,21 @@ gegl_node_add_context (GeglNode *self,
   g_return_val_if_fail (GEGL_IS_NODE (self), NULL);
   g_return_val_if_fail (context_id != NULL, NULL);
 
-#if ENABLE_MT
   g_mutex_lock (self->mutex);
-#endif
   context = g_hash_table_lookup (self->priv->contexts, context_id);
 
   if (context)
     {
       /* silently ignore, since multiple traversals of prepare are done
        * to saturate the graph */
-#if ENABLE_MT
       g_mutex_unlock (self->mutex);
-#endif
       return context;
     }
 
   context             = gegl_operation_context_new ();
   context->operation  = self->operation;
   g_hash_table_insert (self->priv->contexts, context_id, context);
-#if ENABLE_MT
   g_mutex_unlock (self->mutex);
-#endif
   return context;
 }
 
diff --git a/gegl/graph/gegl-node.h b/gegl/graph/gegl-node.h
index f20dc62..2e9263d 100644
--- a/gegl/graph/gegl-node.h
+++ b/gegl/graph/gegl-node.h
@@ -75,9 +75,7 @@ struct _GeglNode
   /* Whether result is cached or not, inherited by children */
   gboolean        dont_cache;
 
-#if ENABLE_MT
   GMutex         *mutex;
-#endif
 
   /*< private >*/
   GeglNodePrivate *priv;
diff --git a/gegl/operation/gegl-operation.c b/gegl/operation/gegl-operation.c
index caf0fc0..c327c7d 100644
--- a/gegl/operation/gegl-operation.c
+++ b/gegl/operation/gegl-operation.c
@@ -278,13 +278,9 @@ gegl_operation_source_get_bounding_box (GeglOperation  *operation,
   if (node)
     {
       GeglRectangle *ret;
-#if ENABLE_MT
       g_mutex_lock (node->mutex);
-#endif
       ret = &node->have_rect;
-#if ENABLE_MT
       g_mutex_unlock (node->mutex);
-#endif
       return ret;
     }
 
diff --git a/gegl/process/gegl-have-visitor.c b/gegl/process/gegl-have-visitor.c
index fc98c78..0d456e7 100644
--- a/gegl/process/gegl-have-visitor.c
+++ b/gegl/process/gegl-have-visitor.c
@@ -64,18 +64,14 @@ gegl_have_visitor_visit_node (GeglVisitor *self,
   if (!node)
     return;
   operation = node->operation;
-#if ENABLE_MT
   g_mutex_lock (node->mutex);
-#endif
   node->have_rect = gegl_operation_get_bounding_box (operation);
 
   GEGL_NOTE (GEGL_DEBUG_PROCESS,
              "For \"%s\" have_rect = %d,%d %dÃ?%d\n",
              gegl_node_get_debug_name (node),
              node->have_rect.x, node->have_rect.y, node->have_rect.width, node->have_rect.height);
-#if ENABLE_MT
   g_mutex_unlock (node->mutex);
-#endif
 
   time = gegl_ticks () - time;
   gegl_instrument ("process", gegl_node_get_operation (node), time);
diff --git a/gegl/process/gegl-prepare-visitor.c b/gegl/process/gegl-prepare-visitor.c
index e430c49..af48e91 100644
--- a/gegl/process/gegl-prepare-visitor.c
+++ b/gegl/process/gegl-prepare-visitor.c
@@ -80,27 +80,19 @@ gegl_prepare_visitor_visit_node (GeglVisitor *self,
         g_assert (graph);
         if (GEGL_NODE (graph)->operation)
           {
-#if ENABLE_MT
             g_mutex_lock (GEGL_NODE (graph)->mutex);
-#endif
             /* issuing a prepare on the graph, FIXME: we might need to do
              * a cycle of prepares as deep as the nesting of graphs,.
              * (or find a better way to do this) */
             gegl_operation_prepare (GEGL_NODE (graph)->operation);
-#if ENABLE_MT
             g_mutex_unlock (GEGL_NODE (graph)->mutex);
-#endif
           }
       }
   }
 
-#if ENABLE_MT
   g_mutex_lock (node->mutex);
-#endif
   gegl_operation_prepare (operation);
-#if ENABLE_MT
   g_mutex_unlock (node->mutex);
-#endif
   {
     /* initialise the "needed rectangle" to an empty one */
     GeglRectangle empty ={0,};



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]