summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-06-24 14:13:45 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-06-24 14:13:45 +0000
commit0f5bdd666fa66bd279f8629a670d8058780a613d (patch)
tree2456f101d56c9d2f091631293f8b85645389f031 /libs/pbd
parentfe229a830e0164e56d3aceaf3d539e4148f322a6 (diff)
use JACK thread creation functions to create process-graph threads; provide GUI control over number of threads-relative-to-number-of-CPUS
git-svn-id: svn://localhost/ardour2/branches/3.0@7296 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/cpus.cc49
-rw-r--r--libs/pbd/pbd/cpus.h28
-rw-r--r--libs/pbd/wscript2
3 files changed, 79 insertions, 0 deletions
diff --git a/libs/pbd/cpus.cc b/libs/pbd/cpus.cc
new file mode 100644
index 0000000000..ba4ba32fe4
--- /dev/null
+++ b/libs/pbd/cpus.cc
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 2010 Paul Davis
+ Author: Torben Hohn
+
+ 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifdef WAF_BUILD
+#include "libpbd-config.h"
+#endif
+
+#ifdef __linux__
+#include <unistd.h>
+#elif defined(__APPLE__) || defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
+#include "pbd/cpus.h"
+
+uint32_t
+hardware_concurrency()
+{
+#if defined(PTW32_VERSION) || defined(__hpux)
+ return pthread_num_processors_np();
+#elif defined(__APPLE__) || defined(__FreeBSD__)
+ int count;
+ size_t size=sizeof(count);
+ return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count;
+#elif defined(HAVE_UNISTD) && defined(_SC_NPROCESSORS_ONLN)
+ int const count=sysconf(_SC_NPROCESSORS_ONLN);
+ return (count>0)?count:0;
+#else
+ return 0;
+#endif
+}
diff --git a/libs/pbd/pbd/cpus.h b/libs/pbd/pbd/cpus.h
new file mode 100644
index 0000000000..1488f30068
--- /dev/null
+++ b/libs/pbd/pbd/cpus.h
@@ -0,0 +1,28 @@
+/*
+ Copyright (C) 2010 Paul Davis
+ Author: Torben Hohn
+
+ 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __libpbd_cpus_h__
+#define __libpbd_cpus_h__
+
+#include <stdint.h>
+
+extern uint32_t hardware_concurrency ();
+
+#endif /* __libpbd_cpus_h__ */
diff --git a/libs/pbd/wscript b/libs/pbd/wscript
index 7052ad98ca..a558a04da2 100644
--- a/libs/pbd/wscript
+++ b/libs/pbd/wscript
@@ -40,6 +40,7 @@ def configure(conf):
conf.check(function_name='getmntent', header_name='mntent.h', define_name='HAVE_GETMNTENT')
conf.check(header_name='execinfo.h', define_name='HAVE_EXECINFO')
+ conf.check(header_name='unistd.h', define_name='HAVE_UNISTD')
conf.write_config_header('libpbd-config.h')
@@ -59,6 +60,7 @@ def build(bld):
controllable.cc
controllable_descriptor.cc
crossthread.cc
+ cpus.cc
debug.cc
enumwriter.cc
event_loop.cc