You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by rh...@apache.org on 2014/02/12 05:34:40 UTC
svn commit: r1567521 - /incubator/log4cxx/trunk/src/main/cpp/threadcxx.cpp
Author: rhys
Date: Wed Feb 12 04:34:39 2014
New Revision: 1567521
URL: http://svn.apache.org/r1567521
Log:
LOG4CXX-337 Attempt to get threadcxx.cpp compiling
r1566630 broke this compilation unit with mismatched
preprocessor directives and making Thread::join()
disappear. I suspect the problem was a patch against
an older version. This is an attempt to get the
file building again by comparing r1566629 against
the patch attached to LOG4CXX-337.
Modified:
incubator/log4cxx/trunk/src/main/cpp/threadcxx.cpp
Modified: incubator/log4cxx/trunk/src/main/cpp/threadcxx.cpp
URL: http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/threadcxx.cpp?rev=1567521&r1=1567520&r2=1567521&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/threadcxx.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/threadcxx.cpp Wed Feb 12 04:34:39 2014
@@ -128,15 +128,15 @@ void* LOG4CXX_THREAD_FUNC ThreadLaunch::
LaunchPackage* package = (LaunchPackage*) data;
ThreadLocal& tls = getThreadLocal();
tls.set(package->getThread());
- LaunchStatus alive(&package->getThread()->alive);
- void* retval = (package->getRunnable())(thread, package->getData());
- apr_thread_exit(thread, 0);
- return retval;
-}
+ {
+ (package->getRunnable())(thread, package->getData());
+ package->getThread()->ending();
+ }
+ apr_thread_exit(thread, 0); // this function never returns !
+ return 0;
+}
#endif
-
-
Thread::Thread() : thread(NULL), alive(0), interruptedStatus(0),
interruptedMutex(NULL), interruptedCondition(NULL) {
}
@@ -184,33 +184,27 @@ void Thread::run(Runnable start, void* d
if (stat != APR_SUCCESS) {
throw ThreadException(stat);
}
- // we need to set alive here already, since we use isAlive() to check
- // if run() has been called in a thread-safe way.
- apr_atomic_set32(&alive, 0xFFFFFFFF);
+ // we need to set alive here already, since we use isAlive() to check
+ // if run() has been called in a thread-safe way.
+ apr_atomic_set32(&alive, 0xFFFFFFFF);
#else
throw ThreadException(LOG4CXX_STR("APR_HAS_THREADS is not true"));
#endif
- LaunchPackage* package = (LaunchPackage*) data;
- ThreadLocal& tls = getThreadLocal();
- tls.set(package->getThread());
- {
- (package->getRunnable())(thread, package->getData());
- package->getThread()->ending();
- }
- apr_thread_exit(thread, 0); // this function never returns !
- return 0;
}
-#endif
- thread = NULL;
- if (stat != APR_SUCCESS) {
- throw ThreadException(stat);
- }
+void Thread::join() {
+#if APR_HAS_THREADS
+ if (thread != NULL) {
+ apr_status_t startStat;
+ apr_status_t stat = apr_thread_join(&startStat, thread);
+ thread = NULL;
+ if (stat != APR_SUCCESS) {
+ throw ThreadException(stat);
}
+ }
#endif
}
-
void Thread::currentThreadInterrupt() {
#if APR_HAS_THREADS
void* tls = getThreadLocal().get();