Avoid excess threads with g_mutex_trylock
authorAndy Spencer <andy753421@gmail.com>
Tue, 9 Feb 2010 17:31:18 +0000 (17:31 +0000)
committerAndy Spencer <andy753421@gmail.com>
Tue, 9 Feb 2010 17:31:18 +0000 (17:31 +0000)
src/plugins/elev.c
src/plugins/map.c
src/plugins/sat.c

index 6599964..9279b08 100644 (file)
@@ -246,7 +246,8 @@ static void _free_tile(GisTile *tile, gpointer _elev)
 static gpointer _update_tiles(gpointer _elev)
 {
        GisPluginElev *elev = _elev;
-       g_mutex_lock(elev->mutex);
+       if (!g_mutex_trylock(elev->mutex))
+               return NULL;
        gdouble lat, lon, elevation;
        gis_viewer_get_location(elev->viewer, &lat, &lon, &elevation);
        gis_tile_update(elev->tiles,
index d304391..7a2d66d 100644 (file)
@@ -134,7 +134,8 @@ static gpointer _update_tiles(gpointer _map)
 {
        g_debug("GisPluginMap: _update_tiles");
        GisPluginMap *map = _map;
-       g_mutex_lock(map->mutex);
+       if (!g_mutex_trylock(map->mutex))
+               return NULL;
        gdouble lat, lon, elev;
        gis_viewer_get_location(map->viewer, &lat, &lon, &elev);
        gis_tile_update(map->tiles,
index fae0c37..1af0bfc 100644 (file)
@@ -125,7 +125,8 @@ static gpointer _update_tiles(gpointer _sat)
 {
        g_debug("GisPluginSat: _update_tiles");
        GisPluginSat *sat = _sat;
-       g_mutex_lock(sat->mutex);
+       if (!g_mutex_trylock(sat->mutex))
+               return NULL;
        gdouble lat, lon, elev;
        gis_viewer_get_location(sat->viewer, &lat, &lon, &elev);
        gis_tile_update(sat->tiles,