You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2006/12/23 01:26:27 UTC
svn commit: r489808 - in
/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent:
Mutex.h Thread.cpp Thread.h
Author: tabish
Date: Fri Dec 22 16:26:26 2006
New Revision: 489808
URL: http://svn.apache.org/viewvc?view=rev&rev=489808
Log:
http://issues.apache.org/activemq/browse/AMQCPP-31
Modified:
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.cpp
incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.h
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h?view=diff&rev=489808&r1=489807&r2=489808
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Mutex.h Fri Dec 22 16:26:26 2006
@@ -25,15 +25,15 @@
#include <list>
#if (defined(__unix__) || defined(unix) || defined(MACOSX)) && !defined(USG)
- #ifndef unix
- #define unix
+ #ifndef AMQCPP_USE_PTHREADS
+ #define AMQCPP_USE_PTHREADS
#endif
#include <pthread.h>
#include <sys/time.h>
#endif
-#if defined(WIN32) || defined(__CYGWIN__) && !defined unix
+#if defined(WIN32) || defined(__CYGWIN__) && !defined AMQCPP_USE_PTHREADS
#include <windows.h>
@@ -63,7 +63,7 @@
/**
* The mutex object.
*/
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
pthread_mutex_t mutex;
std::list<pthread_cond_t*> eventQ;
@@ -84,7 +84,7 @@
*/
Mutex()
{
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutex_init(&mutex, &attr);
@@ -105,7 +105,7 @@
// Unlock the mutex.
unlock();
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
pthread_mutex_destroy(&mutex);
#else
DeleteCriticalSection(&mutex);
@@ -124,7 +124,7 @@
}
else
{
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
pthread_mutex_lock(&mutex);
#else
EnterCriticalSection(&mutex);
@@ -159,7 +159,7 @@
{
lock_owner = 0;
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
pthread_mutex_unlock(&mutex);
#else
LeaveCriticalSection(&mutex);
@@ -206,7 +206,7 @@
this->lock_count = 0;
this->lock_owner = 0;
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
// Create this threads wait event
pthread_cond_t waitEvent;
@@ -305,7 +305,7 @@
if( !eventQ.empty() )
{
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
pthread_cond_signal( eventQ.front() );
eventQ.pop_front();
#else
@@ -329,7 +329,7 @@
"Mutex::NotifyAll - Failed, not Lock Owner!" );
}
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
while(!eventQ.empty())
{
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.cpp?view=diff&rev=489808&r1=489807&r2=489808
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.cpp (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.cpp Fri Dec 22 16:26:26 2006
@@ -18,7 +18,7 @@
#include "Thread.h"
#include <errno.h>
-#ifdef unix
+#ifdef AMQCPP_USE_PTHREADS
#include <errno.h> // EINTR
extern int errno;
#else
@@ -61,7 +61,7 @@
"Thread already started");
}
-#ifdef unix
+#ifdef AMQCPP_USE_PTHREADS
::pthread_attr_init (&attributes);
::pthread_attr_setdetachstate (&attributes, PTHREAD_CREATE_JOINABLE);
@@ -100,7 +100,7 @@
}
if (!this->joined) {
-#ifdef unix
+#ifdef AMQCPP_USE_PTHREADS
::pthread_join(this->threadHandle, NULL);
#else
::WaitForSingleObject (this->threadHandle, INFINITE);
@@ -113,7 +113,7 @@
////////////////////////////////////////////////////////////////////////////////
void Thread::sleep( int millisecs )
{
-#ifdef unix
+#ifdef AMQCPP_USE_PTHREADS
struct timespec rec, rem;
rec.tv_sec = millisecs / 1000;
rec.tv_nsec = (millisecs % 1000) * 1000000;
@@ -131,7 +131,7 @@
////////////////////////////////////////////////////////////////////////////////
unsigned long Thread::getId(void)
{
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
return (long)(pthread_self());
#else
return GetCurrentThreadId();
@@ -139,7 +139,7 @@
}
////////////////////////////////////////////////////////////////////////////////
-#ifdef unix
+#ifdef AMQCPP_USE_PTHREADS
void*
#else
unsigned int WINAPI
@@ -157,7 +157,7 @@
ex.printStackTrace();
}
-#ifdef unix
+#ifdef AMQCPP_USE_PTHREADS
::pthread_attr_destroy( &thread->attributes );
return NULL;
#else
Modified: incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.h
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.h?view=diff&rev=489808&r1=489807&r2=489808
==============================================================================
--- incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.h (original)
+++ incubator/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/concurrent/Thread.h Fri Dec 22 16:26:26 2006
@@ -24,8 +24,8 @@
#if (defined(__unix__) || defined(unix) || defined(MACOSX) || defined(__APPLE__)) && !defined(USG)
- #ifndef unix
- #define unix
+ #ifndef AMQCPP_USE_PTHREADS
+ #define AMQCPP_USE_PTHREADS
#endif
#include <pthread.h>
@@ -51,7 +51,7 @@
*/
Runnable* task;
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
pthread_attr_t attributes;
pthread_t threadHandle;
#else
@@ -125,7 +125,7 @@
private:
// Internal thread handling
- #ifdef unix
+ #ifdef AMQCPP_USE_PTHREADS
static void* runCallback (void* param);
#else
static unsigned int WINAPI runCallback (void* param);