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 ca...@apache.org on 2008/01/03 18:14:35 UTC
svn commit: r608565 - in /logging/log4cxx/trunk/src/main: cpp/class.cpp
cpp/exception.cpp cpp/filewatchdog.cpp cpp/thread.cpp cpp/threadlocal.cpp
include/log4cxx/helpers/exception.h
Author: carnold
Date: Thu Jan 3 09:14:33 2008
New Revision: 608565
URL: http://svn.apache.org/viewvc?rev=608565&view=rev
Log:
LOGCXX-75: Fixes to allow cygwin to run unit tests
Modified:
logging/log4cxx/trunk/src/main/cpp/class.cpp
logging/log4cxx/trunk/src/main/cpp/exception.cpp
logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp
logging/log4cxx/trunk/src/main/cpp/thread.cpp
logging/log4cxx/trunk/src/main/cpp/threadlocal.cpp
logging/log4cxx/trunk/src/main/include/log4cxx/helpers/exception.h
Modified: logging/log4cxx/trunk/src/main/cpp/class.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/class.cpp?rev=608565&r1=608564&r2=608565&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/class.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/class.cpp Thu Jan 3 09:14:33 2008
@@ -155,7 +155,9 @@
RollingFileAppender::registerClass();
SMTPAppender::registerClass();
SocketAppender::registerClass();
+#if APR_HAS_THREADS
SocketHubAppender::registerClass();
+#endif
SyslogAppender::registerClass();
#if APR_HAS_THREADS
TelnetAppender::registerClass();
Modified: logging/log4cxx/trunk/src/main/cpp/exception.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/exception.cpp?rev=608565&r1=608564&r2=608565&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/exception.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/exception.cpp Thu Jan 3 09:14:33 2008
@@ -246,6 +246,10 @@
: Exception(formatMessage(stat)) {
}
+ThreadException::ThreadException(const LogString& msg)
+ : Exception(msg) {
+}
+
ThreadException::ThreadException(const ThreadException &src)
: Exception(src) {
}
Modified: logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp?rev=608565&r1=608564&r2=608565&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/filewatchdog.cpp Thu Jan 3 09:14:33 2008
@@ -23,14 +23,13 @@
#include <apr_atomic.h>
#include <log4cxx/helpers/transcoder.h>
-#if APR_HAS_THREADS
-
-
using namespace log4cxx;
using namespace log4cxx::helpers;
long FileWatchdog::DEFAULT_DELAY = 60000;
+
+#if APR_HAS_THREADS
FileWatchdog::FileWatchdog(const File& file1)
: file(file1), delay(DEFAULT_DELAY), lastModif(0),
Modified: logging/log4cxx/trunk/src/main/cpp/thread.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/thread.cpp?rev=608565&r1=608564&r2=608565&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/thread.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/thread.cpp Thu Jan 3 09:14:33 2008
@@ -26,7 +26,6 @@
using namespace log4cxx::helpers;
using namespace log4cxx;
-#if APR_HAS_THREADS
Thread::Thread() : thread(NULL), alive(0), interruptedStatus(0) {
}
@@ -57,6 +56,7 @@
}
void Thread::run(Runnable start, void* data) {
+#if APR_HAS_THREADS
//
// if attempting a second run method on the same Thread object
// throw an exception
@@ -78,6 +78,9 @@
if (stat != APR_SUCCESS) {
throw ThreadException(stat);
}
+#else
+ throw ThreadException(LOG4CXX_STR("APR_HAS_THREADS is not true"));
+#endif
}
@@ -89,6 +92,7 @@
apr_atomic_set32(alive, 0);
}
+#if APR_HAS_THREADS
void* Thread::launcher(log4cxx_thread_t* thread, void* data) {
LaunchPackage* package = (LaunchPackage*) data;
ThreadLocal& tls = getThreadLocal();
@@ -98,8 +102,10 @@
apr_thread_exit((apr_thread_t*) thread, 0);
return retval;
}
+#endif
void Thread::stop() {
+#if APR_HAS_THREADS
if (thread != NULL) {
apr_status_t stat = apr_thread_exit((apr_thread_t*) thread, 0);
thread = NULL;
@@ -107,9 +113,11 @@
throw ThreadException(stat);
}
}
+#endif
}
void Thread::join() {
+#if APR_HAS_THREADS
if (thread != NULL) {
apr_status_t startStat;
apr_status_t stat = apr_thread_join(&startStat, (apr_thread_t*) thread);
@@ -118,6 +126,7 @@
throw ThreadException(stat);
}
}
+#endif
}
ThreadLocal& Thread::getThreadLocal() {
@@ -126,10 +135,12 @@
}
void Thread::currentThreadInterrupt() {
+#if APR_HAS_THREADS
void* tls = getThreadLocal().get();
if (tls != 0) {
((Thread*) tls)->interrupt();
}
+#endif
}
void Thread::interrupt() {
@@ -137,16 +148,22 @@
}
bool Thread::interrupted() {
+#if APR_HAS_THREADS
void* tls = getThreadLocal().get();
if (tls != 0) {
return apr_atomic_xchg32(&(((Thread*) tls)->interruptedStatus), 0) != 0;
}
+#endif
return false;
}
bool Thread::isCurrentThread() const {
+#if APR_HAS_THREADS
const void* tls = getThreadLocal().get();
return (tls == this);
+#else
+ return true;
+#endif
}
bool Thread::isAlive() {
@@ -156,7 +173,7 @@
void Thread::ending() {
apr_atomic_set32(&alive, 0);
}
-#endif
+
void Thread::sleep(int duration) {
#if APR_HAS_THREADS
Modified: logging/log4cxx/trunk/src/main/cpp/threadlocal.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/threadlocal.cpp?rev=608565&r1=608564&r2=608565&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/threadlocal.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/threadlocal.cpp Thu Jan 3 09:14:33 2008
@@ -22,8 +22,8 @@
using namespace log4cxx::helpers;
using namespace log4cxx;
-#if APR_HAS_THREADS
ThreadLocal::ThreadLocal() {
+#if APR_HAS_THREADS
apr_pool_t** ppool = reinterpret_cast<apr_pool_t**>(&pool);
apr_status_t stat = apr_pool_create(ppool, 0);
if (stat != APR_SUCCESS) {
@@ -34,25 +34,31 @@
if (stat != APR_SUCCESS) {
throw RuntimeException(stat);
}
+#endif
}
ThreadLocal::~ThreadLocal() {
+#if APR_HAS_THREADS
apr_pool_destroy((apr_pool_t*) pool);
+#endif
}
void ThreadLocal::set(void* priv) {
+#if APR_HAS_THREADS
apr_status_t stat = apr_threadkey_private_set(priv, (apr_threadkey_t*) key);
if (stat != APR_SUCCESS) {
throw RuntimeException(stat);
}
+#endif
}
void* ThreadLocal::get() {
void* retval = 0;
+#if APR_HAS_THREADS
apr_status_t stat = apr_threadkey_private_get(&retval, (apr_threadkey_t*) key);
if (stat != APR_SUCCESS) {
throw RuntimeException(stat);
}
+#endif
return retval;
}
-#endif
Modified: logging/log4cxx/trunk/src/main/include/log4cxx/helpers/exception.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/helpers/exception.h?rev=608565&r1=608564&r2=608565&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/helpers/exception.h (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/helpers/exception.h Thu Jan 3 09:14:33 2008
@@ -138,6 +138,7 @@
: public Exception {
public:
ThreadException(log4cxx_status_t stat);
+ ThreadException(const LogString& msg);
ThreadException(const ThreadException &src);
ThreadException& operator=(const ThreadException&);
private: