summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2013-03-17 20:19:25 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2013-03-17 20:19:25 +0100
commit125aaf366c2ae370306f678b9c9c0b408e0d3908 (patch)
tree80d2c9fb1c10a5ca1c734f3de9f23ef37ad18f79 /src
parentec98d1712dbaad2a1c995399f61843cd801a3063 (diff)
downloadcataract-125aaf366c2ae370306f678b9c9c0b408e0d3908.tar.xz
Autodetect number of threads
When number of jobs is not specified, use autodetection of number of processors available in the system. This requires glib-2.35.4, checked during configure. https://bugzilla.gnome.org/show_bug.cgi?id=614930 https://bugzilla.gnome.org/show_bug.cgi?id=687223
Diffstat (limited to 'src')
-rw-r--r--src/cgg.c24
1 files changed, 22 insertions, 2 deletions
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) {