mirror of https://github.com/GNOME/gimp.git
app/base/gimphistogram.c use static mutexes.
2005-02-14 Sven Neumann <sven@gimp.org> * app/base/gimphistogram.c * app/base/pixel-processor.c: use static mutexes.
This commit is contained in:
parent
2655dff1e9
commit
0e1077d61d
|
@ -1,3 +1,8 @@
|
|||
2005-02-14 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/base/gimphistogram.c
|
||||
* app/base/pixel-processor.c: use static mutexes.
|
||||
|
||||
2005-02-14 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* configure.in: allow to enable the threaded tile-swapper code
|
||||
|
|
|
@ -40,7 +40,7 @@ struct _GimpHistogram
|
|||
gint n_channels;
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
GMutex *mutex;
|
||||
GStaticMutex mutex;
|
||||
gint num_slots;
|
||||
gdouble ***tmp_values;
|
||||
gchar *tmp_slots;
|
||||
|
@ -74,8 +74,6 @@ gimp_histogram_new (GimpBaseConfig *config)
|
|||
histogram->n_channels = 0;
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
histogram->mutex = g_mutex_new ();
|
||||
|
||||
histogram->num_slots = config->num_processors;
|
||||
histogram->tmp_slots = g_new0 (gchar, histogram->num_slots);
|
||||
histogram->tmp_values = g_new0 (gdouble **, histogram->num_slots);
|
||||
|
@ -90,8 +88,6 @@ gimp_histogram_free (GimpHistogram *histogram)
|
|||
g_return_if_fail (histogram != NULL);
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
g_mutex_free (histogram->mutex);
|
||||
|
||||
g_free (histogram->tmp_values);
|
||||
g_free (histogram->tmp_slots);
|
||||
#endif
|
||||
|
@ -464,7 +460,7 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
gint slot = 0;
|
||||
|
||||
/* find an unused temporary slot to put our results in and lock it */
|
||||
g_mutex_lock (histogram->mutex);
|
||||
g_static_mutex_lock (&histogram->mutex);
|
||||
|
||||
while (histogram->tmp_slots[slot])
|
||||
slot++;
|
||||
|
@ -472,7 +468,7 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
values = histogram->tmp_values[slot];
|
||||
histogram->tmp_slots[slot] = 1;
|
||||
|
||||
g_mutex_unlock (histogram->mutex);
|
||||
g_static_mutex_unlock (&histogram->mutex);
|
||||
|
||||
#else
|
||||
values = histogram->values;
|
||||
|
@ -632,10 +628,10 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
#ifdef ENABLE_MP
|
||||
/* unlock this slot */
|
||||
/* we shouldn't have to use mutex locks here */
|
||||
g_mutex_lock (histogram->mutex);
|
||||
g_static_mutex_lock (&histogram->mutex);
|
||||
|
||||
histogram->tmp_slots[slot] = 0;
|
||||
|
||||
g_mutex_unlock (histogram->mutex);
|
||||
g_static_mutex_unlock (&histogram->mutex);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ struct _PixelProcessor
|
|||
PixelRegionIterator *PRI;
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
GMutex *mutex;
|
||||
GStaticMutex mutex;
|
||||
gint threads;
|
||||
#endif
|
||||
|
||||
|
@ -82,7 +82,7 @@ do_parallel_regions (PixelProcessor *processor)
|
|||
gint n_tiles = 0;
|
||||
gint i;
|
||||
|
||||
g_mutex_lock (processor->mutex);
|
||||
g_static_mutex_lock (&processor->mutex);
|
||||
|
||||
/* the first thread getting here must not call pixel_regions_process() */
|
||||
if (processor->threads && processor->PRI)
|
||||
|
@ -90,7 +90,7 @@ do_parallel_regions (PixelProcessor *processor)
|
|||
|
||||
if (processor->PRI == NULL)
|
||||
{
|
||||
g_mutex_unlock (processor->mutex);
|
||||
g_static_mutex_unlock (&processor->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ do_parallel_regions (PixelProcessor *processor)
|
|||
tile_lock (tr[i].curtile);
|
||||
}
|
||||
|
||||
g_mutex_unlock (processor->mutex);
|
||||
g_static_mutex_unlock (&processor->mutex);
|
||||
n_tiles++;
|
||||
|
||||
switch(processor->num_regions)
|
||||
|
@ -143,7 +143,7 @@ do_parallel_regions (PixelProcessor *processor)
|
|||
break;
|
||||
}
|
||||
|
||||
g_mutex_lock (processor->mutex);
|
||||
g_static_mutex_lock (&processor->mutex);
|
||||
|
||||
for (i = 0; i < processor->num_regions; i++)
|
||||
if (processor->regions[i])
|
||||
|
@ -156,7 +156,7 @@ do_parallel_regions (PixelProcessor *processor)
|
|||
while (processor->PRI &&
|
||||
(processor->PRI = pixel_regions_process (processor->PRI)));
|
||||
|
||||
g_mutex_unlock (processor->mutex);
|
||||
g_static_mutex_unlock (&processor->mutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -314,15 +314,10 @@ pixel_regions_process_parallel_valist (PixelProcessorFunc func,
|
|||
processor.num_regions = num_regions;
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
processor.mutex = g_mutex_new ();
|
||||
processor.threads = 0;
|
||||
#endif
|
||||
|
||||
pixel_regions_do_parallel (&processor);
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
g_mutex_free (processor.mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue