From a44b60593ab559f66ac3e984eb89133b8ca1e260 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 5 Sep 2011 23:30:20 +0000 Subject: Improve logging with multiple threads and processes. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1165450 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/kernel/parallel.hpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'sca-cpp/trunk/kernel/parallel.hpp') 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 #ifdef WANT_THREADS #include -#include -#include #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 /** -- cgit v1.2.3