[file-roller: 2/8] Add function to define thread count
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller: 2/8] Add function to define thread count
- Date: Tue, 6 Apr 2021 05:44:29 +0000 (UTC)
commit d9bf793c50e71372c112d6fbe547640bc7330d87
Author: Julian Groß <firedefender1 googlemail com>
Date: Sun Mar 14 20:03:34 2021 +0100
Add function to define thread count
src/fr-thread-count.c | 36 ++++++++++++++++++++++++++++++++++++
src/fr-thread-count.h | 29 +++++++++++++++++++++++++++++
src/meson.build | 1 +
3 files changed, 66 insertions(+)
---
diff --git a/src/fr-thread-count.c b/src/fr-thread-count.c
new file mode 100644
index 00000000..800144d1
--- /dev/null
+++ b/src/fr-thread-count.c
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * File-Roller
+ *
+ * Copyright (C) 2021 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include "fr-thread-count.h"
+
+gchar *
+fr_get_thread_count (void)
+{
+ gchar *cpus;
+ if (g_get_num_processors() >= 8)
+ cpus = g_strdup_printf("%u", g_get_num_processors() - 2);
+ else if (g_get_num_processors() >= 4)
+ cpus = g_strdup_printf("%u", g_get_num_processors() - 1);
+ else
+ cpus = g_strdup_printf("%u", g_get_num_processors());
+ return cpus;
+}
diff --git a/src/fr-thread-count.h b/src/fr-thread-count.h
new file mode 100644
index 00000000..a8f34aef
--- /dev/null
+++ b/src/fr-thread-count.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * File-Roller
+ *
+ * Copyright (C) 2021 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FR_THREAD_COUNT_H
+#define FR_THREAD_COUNT_H
+
+#include <glib.h>
+
+gchar * fr_get_thread_count (void);
+
+#endif /* FR_THREAD_COUNT_H */
diff --git a/src/meson.build b/src/meson.build
index 8083aacc..7e3cdee3 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -44,6 +44,7 @@ source_files = files(
'fr-location-bar.c',
'fr-new-archive-dialog.c',
'fr-process.c',
+ 'fr-thread-count.c',
'fr-window-actions-callbacks.c',
'fr-window.c',
'gio-utils.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]