summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Makefile.am4
-rw-r--r--cpp/src/qpid/broker/Broker.cpp3
-rw-r--r--cpp/src/qpid/sys/SystemInfo.cpp35
-rw-r--r--cpp/src/qpid/sys/SystemInfo.h44
-rwxr-xr-xcpp/src/tests/perfdist1
5 files changed, 85 insertions, 2 deletions
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am
index a0f01fefe8..120c589d19 100644
--- a/cpp/src/Makefile.am
+++ b/cpp/src/Makefile.am
@@ -128,7 +128,7 @@ libqpidcommon_la_SOURCES = \
qpid/sys/AsynchIOAcceptor.cpp \
qpid/sys/Dispatcher.cpp \
qpid/sys/Runnable.cpp \
- qpid/sys/RefCountedMap.h \
+ qpid/sys/SystemInfo.cpp \
qpid/sys/Serializer.cpp \
qpid/sys/Shlib.cpp \
qpid/Options.cpp \
@@ -401,9 +401,11 @@ nobase_include_HEADERS = \
qpid/sys/Mutex.h \
qpid/sys/Poller.h \
qpid/sys/Runnable.h \
+ qpid/sys/RefCountedMap.h \
qpid/sys/ScopedIncrement.h \
qpid/sys/Semaphore.h \
qpid/sys/Serializer.h \
+ qpid/sys/SystemInfo.h \
qpid/sys/Shlib.h \
qpid/sys/ShutdownHandler.h \
qpid/sys/Socket.h \
diff --git a/cpp/src/qpid/broker/Broker.cpp b/cpp/src/qpid/broker/Broker.cpp
index a02ec432f6..68590d3331 100644
--- a/cpp/src/qpid/broker/Broker.cpp
+++ b/cpp/src/qpid/broker/Broker.cpp
@@ -39,6 +39,7 @@
#include "qpid/sys/ConnectionInputHandler.h"
#include "qpid/sys/ConnectionInputHandlerFactory.h"
#include "qpid/sys/TimeoutHandler.h"
+#include "qpid/sys/SystemInfo.h"
#include <boost/bind.hpp>
@@ -68,6 +69,8 @@ Broker::Options::Options(const std::string& name) :
mgmtPubInterval(10),
ack(100)
{
+ int c = sys::SystemInfo::concurrency();
+ if (c > 0) workerThreads=c;
addOptions()
("port,p", optValue(port,"PORT"),
"Tells the broker to listen on PORT")
diff --git a/cpp/src/qpid/sys/SystemInfo.cpp b/cpp/src/qpid/sys/SystemInfo.cpp
new file mode 100644
index 0000000000..dcc7ad9985
--- /dev/null
+++ b/cpp/src/qpid/sys/SystemInfo.cpp
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "SystemInfo.h"
+#include <unistd.h>
+
+namespace qpid {
+namespace sys {
+
+long SystemInfo::concurrency() {
+#ifdef _SC_NPROCESSORS_ONLN // Linux specific.
+ return sysconf(_SC_NPROCESSORS_ONLN);
+#else
+ return -1;
+#endif
+}
+
+}} // namespace qpid::sys
diff --git a/cpp/src/qpid/sys/SystemInfo.h b/cpp/src/qpid/sys/SystemInfo.h
new file mode 100644
index 0000000000..73c3ca3c17
--- /dev/null
+++ b/cpp/src/qpid/sys/SystemInfo.h
@@ -0,0 +1,44 @@
+#ifndef QPID_SYS_SYSTEMINFO_H
+#define QPID_SYS_SYSTEMINFO_H
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+namespace qpid {
+namespace sys {
+
+/**
+ * Retrieve information about the system we are running on.
+ * Results may be dependent on OS/hardware.
+ */
+class SystemInfo
+{
+ public:
+ /** Estimate available concurrency, e.g. number of CPU cores.
+ * -1 means estimate not available on this platform.
+ */
+ static long concurrency();
+};
+
+}} // namespace qpid::sys
+
+
+
+#endif /*!QPID_SYS_SYSTEMINFO_H*/
diff --git a/cpp/src/tests/perfdist b/cpp/src/tests/perfdist
index 07338f6822..6c5d6b6b11 100755
--- a/cpp/src/tests/perfdist
+++ b/cpp/src/tests/perfdist
@@ -1,6 +1,5 @@
#!/bin/bash
#
-echo $_
usage() {
cat <<EOF
Distributed perftest with ssh.