summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/kernel/parallel.hpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-09-05 23:30:20 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-09-05 23:30:20 +0000
commita44b60593ab559f66ac3e984eb89133b8ca1e260 (patch)
tree2b7c230b3dae78c48e36f626c3b466b9eff9cb27 /sca-cpp/trunk/kernel/parallel.hpp
parent4f1cd537bc7c5a35f03660c4d04754954fae0487 (diff)
Improve logging with multiple threads and processes.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1165450 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/kernel/parallel.hpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/sca-cpp/trunk/kernel/parallel.hpp b/sca-cpp/trunk/kernel/parallel.hpp
index 648cd60cfc..57754a33e6 100644
--- a/sca-cpp/trunk/kernel/parallel.hpp
+++ b/sca-cpp/trunk/kernel/parallel.hpp
@@ -26,10 +26,9 @@
* Simple parallel work execution functions.
*/
+#include <unistd.h>
#ifdef WANT_THREADS
#include <pthread.h>
-#include <sys/syscall.h>
-#include <unistd.h>
#endif
#include "function.hpp"
@@ -37,17 +36,20 @@
namespace tuscany {
+/**
+ * Returns the current process id.
+ */
+unsigned long processId() {
+ return (unsigned long)getpid();
+}
+
#ifdef WANT_THREADS
/**
* Returns the current thread id.
*/
-long int threadId() {
-#ifdef IS_DARWIN
- return syscall(SYS_thread_selfid);
-#else
- return syscall(SYS_gettid);
-#endif
+unsigned long threadId() {
+ return (unsigned long)pthread_self();
}
/**
@@ -317,6 +319,15 @@ const bool cancel(worker& w) {
return true;
}
+#else
+
+/**
+ * Returns the current thread id.
+ */
+unsigned long threadId() {
+ return 0;
+}
+
#endif
/**