Remove deprecated thread functions
authorAndy Spencer <andy753421@gmail.com>
Thu, 13 Dec 2012 05:42:02 +0000 (05:42 +0000)
committerAndy Spencer <andy753421@gmail.com>
Thu, 13 Dec 2012 05:42:02 +0000 (05:42 +0000)
src/grits-demo.c
src/grits-opengl.c
src/grits-opengl.h
src/grits-test.c
src/objects/grits-object.c
src/plugins/elev.c
src/plugins/elev.h
src/tile-test.c

index d9532f4..e5f18b6 100644 (file)
@@ -166,7 +166,6 @@ static void restore_states(GtkUIManager *manager)
 
 int main(int argc, char **argv)
 {
-       g_thread_init(NULL);
        gdk_threads_init();
        gtk_init(&argc, &argv);
 
index a2dce84..a6eb92c 100644 (file)
@@ -135,9 +135,9 @@ static void _set_visuals(GritsOpenGL *opengl)
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        //glShadeModel(GL_FLAT);
 
-       g_mutex_lock(opengl->sphere_lock);
+       g_mutex_lock(&opengl->sphere_lock);
        roam_sphere_update_view(opengl->sphere);
-       g_mutex_unlock(opengl->sphere_lock);
+       g_mutex_unlock(&opengl->sphere_lock);
 }
 
 static GPtrArray *_objects_to_array(GritsOpenGL *opengl, gboolean ortho)
@@ -165,9 +165,9 @@ static gboolean on_configure(GritsOpenGL *opengl, GdkEventConfigure *event, gpoi
 
        _set_visuals(opengl);
 #ifndef ROAM_DEBUG
-       g_mutex_lock(opengl->sphere_lock);
+       g_mutex_lock(&opengl->sphere_lock);
        roam_sphere_update_errors(opengl->sphere);
-       g_mutex_unlock(opengl->sphere_lock);
+       g_mutex_unlock(&opengl->sphere_lock);
 #endif
 
        return FALSE;
@@ -236,7 +236,7 @@ static gboolean on_motion_notify(GritsOpenGL *opengl, GdkEventMotion *event, gpo
        glMatrixMode(GL_MODELVIEW);  glPushMatrix();
        glMatrixMode(GL_PROJECTION); glPushMatrix();
 
-       g_mutex_lock(opengl->objects_lock);
+       g_mutex_lock(&opengl->objects_lock);
 
        GritsObject *top = NULL;
        GPtrArray *ortho = _objects_to_array(opengl, TRUE);
@@ -271,7 +271,7 @@ static gboolean on_motion_notify(GritsOpenGL *opengl, GdkEventMotion *event, gpo
        g_ptr_array_free(world, TRUE);
        g_ptr_array_free(ortho, TRUE);
 
-       g_mutex_unlock(opengl->objects_lock);
+       g_mutex_unlock(&opengl->objects_lock);
 
 
        /* Test unproject */
@@ -369,11 +369,11 @@ static gboolean on_expose(GritsOpenGL *opengl, GdkEventExpose *event, gpointer _
        (void)_draw_level;
        //roam_sphere_draw_normals(opengl->sphere);
 #else
-       g_mutex_lock(opengl->objects_lock);
+       g_mutex_lock(&opengl->objects_lock);
        if (opengl->wireframe)
                glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        g_queue_foreach(opengl->objects, _draw_level, opengl);
-       g_mutex_unlock(opengl->objects_lock);
+       g_mutex_unlock(&opengl->objects_lock);
 #endif
 
        gtk_gl_end(GTK_WIDGET(opengl));
@@ -424,9 +424,9 @@ static gboolean on_chained_event(GritsOpenGL *opengl, GdkEvent *event, gpointer
 static gboolean _update_errors_cb(gpointer _opengl)
 {
        GritsOpenGL *opengl = _opengl;
-       g_mutex_lock(opengl->sphere_lock);
+       g_mutex_lock(&opengl->sphere_lock);
        roam_sphere_update_errors(opengl->sphere);
-       g_mutex_unlock(opengl->sphere_lock);
+       g_mutex_unlock(&opengl->sphere_lock);
        opengl->ue_source = 0;
        return FALSE;
 }
@@ -448,10 +448,10 @@ static void on_view_changed(GritsOpenGL *opengl,
 static gboolean on_idle(GritsOpenGL *opengl)
 {
        //g_debug("GritsOpenGL: on_idle");
-       g_mutex_lock(opengl->sphere_lock);
+       g_mutex_lock(&opengl->sphere_lock);
        if (roam_sphere_split_merge(opengl->sphere))
                gtk_widget_queue_draw(GTK_WIDGET(opengl));
-       g_mutex_unlock(opengl->sphere_lock);
+       g_mutex_unlock(&opengl->sphere_lock);
        return TRUE;
 }
 
@@ -561,7 +561,7 @@ static void grits_opengl_set_height_func(GritsViewer *_opengl, GritsBounds *boun
 {
        GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
        /* TODO: get points? */
-       g_mutex_lock(opengl->sphere_lock);
+       g_mutex_lock(&opengl->sphere_lock);
        GList *triangles = roam_sphere_get_intersect(opengl->sphere, TRUE,
                        bounds->n, bounds->s, bounds->e, bounds->w);
        for (GList *cur = triangles; cur; cur = cur->next) {
@@ -577,7 +577,7 @@ static void grits_opengl_set_height_func(GritsViewer *_opengl, GritsBounds *boun
                }
        }
        g_list_free(triangles);
-       g_mutex_unlock(opengl->sphere_lock);
+       g_mutex_unlock(&opengl->sphere_lock);
 }
 
 static void _grits_opengl_clear_height_func_rec(RoamTriangle *root)
@@ -631,7 +631,7 @@ static gpointer grits_opengl_add(GritsViewer *_opengl, GritsObject *object,
 {
        g_assert(GRITS_IS_OPENGL(_opengl));
        GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
-       g_mutex_lock(opengl->objects_lock);
+       g_mutex_lock(&opengl->objects_lock);
        struct RenderLevel *level = NULL;
        GList *tmp = g_queue_find_custom(opengl->objects, &num, _objects_find);
        if (tmp) {
@@ -650,7 +650,7 @@ static gpointer grits_opengl_add(GritsViewer *_opengl, GritsObject *object,
        if (list->next)
                list->next->prev = link;
        list->next = link;
-       g_mutex_unlock(opengl->objects_lock);
+       g_mutex_unlock(&opengl->objects_lock);
        return link;
 }
 
@@ -659,12 +659,12 @@ static GritsObject *grits_opengl_remove(GritsViewer *_opengl, GritsObject *objec
        g_assert(GRITS_IS_OPENGL(_opengl));
        GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
        GList *link = object->ref;
-       g_mutex_lock(opengl->objects_lock);
+       g_mutex_lock(&opengl->objects_lock);
        /* Just unlink and free it, link->prev is assured */
        link->prev->next = link->next;
        if (link->next)
                link->next->prev = link->prev;
-       g_mutex_unlock(opengl->objects_lock);
+       g_mutex_unlock(&opengl->objects_lock);
        object->ref    = NULL;
        object->viewer = NULL;
        g_free(link);
@@ -679,10 +679,10 @@ G_DEFINE_TYPE(GritsOpenGL, grits_opengl, GRITS_TYPE_VIEWER);
 static void grits_opengl_init(GritsOpenGL *opengl)
 {
        g_debug("GritsOpenGL: init");
-       opengl->objects      = g_queue_new();
-       opengl->objects_lock = g_mutex_new();
-       opengl->sphere       = roam_sphere_new(opengl);
-       opengl->sphere_lock  = g_mutex_new();
+       opengl->objects = g_queue_new();
+       opengl->sphere  = roam_sphere_new(opengl);
+       g_mutex_init(&opengl->objects_lock);
+       g_mutex_init(&opengl->sphere_lock);
        gtk_gl_enable(GTK_WIDGET(opengl));
        gtk_widget_add_events(GTK_WIDGET(opengl), GDK_KEY_PRESS_MASK);
        g_signal_connect(opengl, "map", G_CALLBACK(on_realize), NULL);
@@ -712,8 +712,8 @@ static void grits_opengl_finalize(GObject *_opengl)
        roam_sphere_free(opengl->sphere);
        g_queue_foreach(opengl->objects, _objects_free, NULL);
        g_queue_free(opengl->objects);
-       g_mutex_free(opengl->objects_lock);
-       g_mutex_free(opengl->sphere_lock);
+       g_mutex_clear(&opengl->objects_lock);
+       g_mutex_clear(&opengl->sphere_lock);
        G_OBJECT_CLASS(grits_opengl_parent_class)->finalize(_opengl);
 }
 static void grits_opengl_class_init(GritsOpenGLClass *klass)
index 0686df3..3e95b00 100644 (file)
@@ -39,9 +39,9 @@ struct _GritsOpenGL {
 
        /* instance members */
        GQueue     *objects;
-       GMutex     *objects_lock;
+       GMutex      objects_lock;
        RoamSphere *sphere;
-       GMutex     *sphere_lock;
+       GMutex      sphere_lock;
        guint       sm_source[2];
        guint       ue_source;
 
index 07edaf7..10d59ec 100644 (file)
@@ -65,7 +65,6 @@ static void load_plugin(GritsPlugins *plugins, gchar *name,
  ***********/
 int main(int argc, char **argv)
 {
-       g_thread_init(NULL);
        gdk_threads_init();
        gtk_init(&argc, &argv);
 
index a1e80ec..4674e8a 100644 (file)
@@ -111,7 +111,7 @@ void grits_object_pickdraw(GritsObject *object, GritsOpenGL *opengl, gboolean pi
        }
 
        /* Save state, draw, restore state */
-       g_mutex_lock(opengl->sphere_lock);
+       g_mutex_lock(&opengl->sphere_lock);
        if (!(object->skip & GRITS_SKIP_STATE)) {
                glPushAttrib(GL_ALL_ATTRIB_BITS);
                glMatrixMode(GL_PROJECTION); glPushMatrix();
@@ -134,7 +134,7 @@ void grits_object_pickdraw(GritsObject *object, GritsOpenGL *opengl, gboolean pi
                glMatrixMode(GL_PROJECTION); glPopMatrix();
                glMatrixMode(GL_MODELVIEW);  glPopMatrix();
        }
-       g_mutex_unlock(opengl->sphere_lock);
+       g_mutex_unlock(&opengl->sphere_lock);
 }
 
 /**
index 765e970..588b576 100644 (file)
@@ -245,7 +245,7 @@ static void _free_tile(GritsTile *tile, gpointer _elev)
 static gpointer _update_tiles(gpointer _elev)
 {
        GritsPluginElev *elev = _elev;
-       if (!g_mutex_trylock(elev->mutex))
+       if (!g_mutex_trylock(&elev->mutex))
                return NULL;
        GritsPoint eye;
        grits_viewer_get_location(elev->viewer, &eye.lat, &eye.lon, &eye.elev);
@@ -254,7 +254,7 @@ static gpointer _update_tiles(gpointer _elev)
                        _load_tile, elev);
        grits_tile_gc(elev->tiles, time(NULL)-10,
                        _free_tile, elev);
-       g_mutex_unlock(elev->mutex);
+       g_mutex_unlock(&elev->mutex);
        return NULL;
 }
 
@@ -264,7 +264,7 @@ static gpointer _update_tiles(gpointer _elev)
 static void _on_location_changed(GritsViewer *viewer,
                gdouble lat, gdouble lon, gdouble elevation, GritsPluginElev *elev)
 {
-       g_thread_create(_update_tiles, elev, FALSE, NULL);
+       g_thread_new("update-tiles-thread", _update_tiles, elev);
 }
 
 static gpointer _threaded_init(GritsPluginElev *elev)
@@ -292,7 +292,7 @@ GritsPluginElev *grits_plugin_elev_new(GritsViewer *viewer)
        elev->viewer = g_object_ref(viewer);
 
        /* Load initial tiles */
-       g_thread_create((GThreadFunc)_threaded_init, elev, FALSE, NULL);
+       g_thread_new("init-thread", (GThreadFunc)_threaded_init, elev);
 
        /* Connect signals */
        elev->sigid = g_signal_connect(elev->viewer, "location-changed",
@@ -324,7 +324,7 @@ static void grits_plugin_elev_init(GritsPluginElev *elev)
 {
        g_debug("GritsPluginElev: init");
        /* Set defaults */
-       elev->mutex = g_mutex_new();
+       g_mutex_init(&elev->mutex);
        elev->tiles = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
        elev->wms   = grits_wms_new(
                "http://www.nasa.network.com/elev", "mergedSrtm", "application/bil",
@@ -353,9 +353,9 @@ static void grits_plugin_elev_finalize(GObject *gobject)
        /* Free data */
        grits_tile_free(elev->tiles, _free_tile, elev);
        grits_wms_free(elev->wms);
-       g_mutex_lock(elev->mutex);
-       g_mutex_unlock(elev->mutex);
-       g_mutex_free(elev->mutex);
+       g_mutex_lock(&elev->mutex);
+       g_mutex_unlock(&elev->mutex);
+       g_mutex_clear(&elev->mutex);
        G_OBJECT_CLASS(grits_plugin_elev_parent_class)->finalize(gobject);
 
 }
index 9f09c3e..c116dc9 100644 (file)
@@ -37,7 +37,7 @@ struct _GritsPluginElev {
        GritsViewer *viewer;
        GritsTile   *tiles;
        GritsWms    *wms;
-       GMutex      *mutex;
+       GMutex       mutex;
        gulong       sigid;
 };
 
index 8be6fe9..aeb01ff 100644 (file)
@@ -134,7 +134,6 @@ gboolean key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 
 int main(int argc, char **argv)
 {
-       g_thread_init(NULL);
        gdk_threads_init();
        gtk_init(&argc, &argv);
 
@@ -160,9 +159,9 @@ int main(int argc, char **argv)
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
-       g_thread_create(do_bmng_cache, bmng_image, FALSE, NULL);
-       g_thread_create(do_osm_cache,  osm_image,  FALSE, NULL);
-       g_thread_create(do_osm2_cache, osm2_image, FALSE, NULL);
+       g_thread_new("bmng-thread", do_bmng_cache, bmng_image);
+       g_thread_new("osm-thread",  do_osm_cache,  osm_image);
+       g_thread_new("osm2-thread", do_osm2_cache, osm2_image);
 
        gtk_widget_show_all(win);
        gtk_main();