summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac7
-rw-r--r--src/cgg.c24
2 files changed, 29 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 2f91601..907a1df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,6 +70,13 @@ AC_SUBST(WARN_CFLAGS)
dnl **************************************************
+dnl *** Check for g_get_num_processors() presence ***
+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 EXIV2 version ***
dnl **************************************************
AC_MSG_CHECKING(for EXIV2 - version >= $EXIV2_REQUIRED)
diff --git a/src/cgg.c b/src/cgg.c
index 55691bf..7510d2e 100644
--- a/src/cgg.c
+++ b/src/cgg.c
@@ -44,7 +44,7 @@ static gchar *dst_dir = NULL;
static gboolean verbose = FALSE;
static gboolean update = FALSE;
static gboolean fullsize = FALSE;
-static int jobs = 1;
+static int jobs = 0;
@@ -59,7 +59,13 @@ parse_cmd (int argc, char *argv[])
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
{ "source", 's', 0, G_OPTION_ARG_STRING, &source_dir, "Specifies a path to source structure", NULL },
{ "output", 'o', 0, G_OPTION_ARG_STRING, &dst_dir, "Generate files to the specified directory instead of current", NULL },
- { "jobs", 'j', 0, G_OPTION_ARG_INT, &jobs, "Allow N jobs at once (default=1)", NULL },
+ { "jobs", 'j', 0, G_OPTION_ARG_INT, &jobs, "Allow N jobs at once"
+#ifdef HAVE_G_GET_NUM_PROCESSORS
+ " (default=autodetect)",
+#else
+ " (default=1)",
+#endif
+ NULL },
{ "update", 'u', 0, G_OPTION_ARG_NONE, &update, "Update the output structure", NULL },
{ "fullsize", 'f', 0, G_OPTION_ARG_NONE, &fullsize, "Override the nofullsize switch and generate full gallery", NULL },
{ NULL }
@@ -166,6 +172,20 @@ main (int argc, char* argv[])
printf ("Using setup file \"%s\"\n", setup->setup_xml_path);
}
+ /* Setup number of threads */
+ if (jobs == 0) {
+#ifdef HAVE_G_GET_NUM_PROCESSORS
+ jobs = g_get_num_processors ();
+#else
+ jobs = 1;
+#endif
+ if (verbose)
+ printf ("Number of jobs: %d (autodetected)\n", jobs);
+ } else {
+ if (verbose)
+ printf ("Number of jobs: %d\n", jobs);
+ }
+
/* Setup feeds */
news_feed = NULL;
if (setup->feed_enabled) {