diff options
| author | Tomas Bzatek <tbzatek@redhat.com> | 2013-04-22 15:29:43 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@redhat.com> | 2013-04-22 15:30:18 +0200 |
| commit | 3a6563d039e38a171ce5a5c09ecfe7981797e2c4 (patch) | |
| tree | 873f2a0072f8d045c71a735b38bb72f3f1248394 | |
| parent | 14763f09fe457dc1781ef8b15014496ebae536cf (diff) | |
| download | cataract-3a6563d039e38a171ce5a5c09ecfe7981797e2c4.tar.xz | |
Use new glib threading API
The gthread library has been merged in glib and the threading API has changed
a little. Since changes are negligible, there's no point of losing support
of older glib releases, thus make it conditional.
| -rw-r--r-- | configure.ac | 6 | ||||
| -rw-r--r-- | src/cgg.c | 2 | ||||
| -rw-r--r-- | src/job-manager.c | 6 |
3 files changed, 13 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index cc2c10e..f439459 100644 --- a/configure.ac +++ b/configure.ac @@ -75,6 +75,12 @@ dnl ************************************************** AC_CHECK_LIB(glib-2.0, g_get_num_processors, [ AC_DEFINE(HAVE_G_GET_NUM_PROCESSORS, 1, [Define if glib has g_get_num_processors()])]) +dnl ************************************************** +dnl *** Check for new glib threading API *** +dnl ************************************************** +AC_CHECK_LIB(glib-2.0, g_thread_new, [ + AC_DEFINE(HAVE_GLIB_NEW_THREADS, 1, [Define if glib has new threading API])]) + dnl ************************************************** dnl *** Check for EXIV2 version *** @@ -125,7 +125,9 @@ main (int argc, char* argv[]) */ LIBXML_TEST_VERSION; +#ifndef HAVE_GLIB_NEW_THREADS g_thread_init (NULL); +#endif /* Initialize ImageMagick at this point, for multithreading safety */ MagickWandGenesis(); diff --git a/src/job-manager.c b/src/job-manager.c index 8044b7f..fd41550 100644 --- a/src/job-manager.c +++ b/src/job-manager.c @@ -370,7 +370,11 @@ build_tree (TGallerySetup *setup, for (i = 0; i < jobs; i++) { error = NULL; +#ifdef HAVE_GLIB_NEW_THREADS + thread = g_thread_try_new (NULL, thread_func, job, &error); +#else thread = g_thread_create (thread_func, job, TRUE, &error); +#endif if (thread) thread_list = g_list_append (thread_list, thread); if (error) { @@ -381,9 +385,9 @@ build_tree (TGallerySetup *setup, /* wait for threads are finished */ for (l = thread_list; l != NULL; l = l->next) { + /* also unrefs the thread instance */ g_thread_join (l->data); } - /* TODO: free threads? */ g_list_free (thread_list); #else /* threads are disabled */ |
