You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/01/03 03:52:57 UTC
svn commit: r492028 - in /incubator/tuscany/cpp/sca:
VSExpress/tuscany_sca/tuscany_sca/tuscany_sca.vcproj
runtime/core/src/tuscany/sca/util/ThreadLocal.cpp
runtime/core/src/tuscany/sca/util/ThreadLocal.h
Author: jsdelfino
Date: Tue Jan 2 18:52:56 2007
New Revision: 492028
URL: http://svn.apache.org/viewvc?view=rev&rev=492028
Log:
Ported the ThreadLocal implementation to Windows.
Modified:
incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca/tuscany_sca.vcproj
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.cpp
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.h
Modified: incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca/tuscany_sca.vcproj
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca/tuscany_sca.vcproj?view=diff&rev=492028&r1=492027&r2=492028
==============================================================================
--- incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca/tuscany_sca.vcproj (original)
+++ incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca/tuscany_sca.vcproj Tue Jan 2 18:52:56 2007
@@ -1014,6 +1014,14 @@
>
</File>
<File
+ RelativePath="..\..\..\runtime\core\src\tuscany\sca\util\ThreadLocal.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\core\src\tuscany\sca\util\ThreadLocal.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\runtime\core\src\tuscany\sca\util\Utils.cpp"
>
<FileConfiguration
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.cpp?view=diff&rev=492028&r1=492027&r2=492028
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.cpp Tue Jan 2 18:52:56 2007
@@ -47,6 +47,13 @@
{
logentry();
#if defined(WIN32) || defined (_WINDOWS)
+ index = TlsAlloc();
+ if (index == TLS_OUT_OF_INDEXES)
+ {
+ ostringstream msg;
+ msg << "Failed to create thread local index, error: " << GetLastError();
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
#else
int rc = pthread_key_create(&key, NULL);
if (rc)
@@ -62,6 +69,12 @@
{
logentry();
#if defined(WIN32) || defined (_WINDOWS)
+ if (!TlsFree(index))
+ {
+ ostringstream msg;
+ msg << "Failed to destroy thread local index, error: " << GetLastError();
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
#else
int rc = pthread_key_delete(key);
if (rc) {
@@ -72,10 +85,16 @@
#endif
}
- void ThreadLocal::setValue(const void* value)
+ void ThreadLocal::setValue(void* value)
{
logentry();
#if defined(WIN32) || defined (_WINDOWS)
+ if (!TlsSetValue(index, value))
+ {
+ ostringstream msg;
+ msg << "Failed to set thread local value, error: " << GetLastError();
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
#else
int rc = pthread_setspecific(key, value);
if (rc) {
@@ -90,6 +109,7 @@
{
logentry();
#if defined(WIN32) || defined (_WINDOWS)
+ return TlsGetValue(index);
#else
return pthread_getspecific(key);
#endif
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.h?view=diff&rev=492028&r1=492027&r2=492028
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/ThreadLocal.h Tue Jan 2 18:52:56 2007
@@ -57,7 +57,7 @@
/**
* Set the ThreadLocal value.
*/
- void setValue(const void *value);
+ void setValue(void *value);
/**
* Get the ThreadLocal value.
@@ -70,6 +70,7 @@
* Handle to the thread local key.
*/
#if defined(WIN32) || defined (_WINDOWS)
+ DWORD index;
#else
pthread_key_t key;
#endif
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org