damitha 2003/09/08 03:22:52
Modified: c/src/engine SharedObject.cpp SharedObject.h
Log:
Sorry I did not make the code windows compatible
in my earlier commit. Here I have corrected my mistake
Revision Changes Path
1.5 +22 -5 xml-axis/c/src/engine/SharedObject.cpp
Index: SharedObject.cpp
===================================================================
RCS file: /home/cvs/xml-axis/c/src/engine/SharedObject.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SharedObject.cpp 5 Sep 2003 12:11:28 -0000 1.4
+++ SharedObject.cpp 8 Sep 2003 10:22:52 -0000 1.5
@@ -72,26 +72,43 @@
SharedObject::SharedObject()
{
m_bLocked = false;
- mut = new pthread_mutex_t;
- pthread_mutex_init(mut, NULL);
+ #ifdef WIN32
+ #else //Linux
+ mut = new pthread_mutex_t;
+ pthread_mutex_init(mut, NULL);
+ #endif
}
SharedObject::~SharedObject()
{
- pthread_mutex_destroy(mut);
+ #ifdef WIN32
+ #else //Linux
+ pthread_mutex_destroy(mut);
+ #endif
}
//Following functions should be improved to avoid chances of failure
//using platform specific mechanisms
int SharedObject::lock()
{
- pthread_mutex_lock(mut);
+ #ifdef WIN32
+ while (m_bLocked)
+ {
+ Ax_Sleep(0);
+ }
+
+ #else //Linux
+ pthread_mutex_lock(mut);
+ #endif
m_bLocked = true;
return 0;
}
int SharedObject::unlock()
{
- pthread_mutex_unlock(mut);
+ #ifdef WIN32
+ #else //Linux
+ pthread_mutex_unlock(mut);
+ #endif
m_bLocked = false;
return 0;
}
1.6 +4 -1 xml-axis/c/src/engine/SharedObject.h
Index: SharedObject.h
===================================================================
RCS file: /home/cvs/xml-axis/c/src/engine/SharedObject.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SharedObject.h 5 Sep 2003 12:11:28 -0000 1.5
+++ SharedObject.h 8 Sep 2003 10:22:52 -0000 1.6
@@ -79,7 +79,10 @@
int lock();
private:
bool m_bLocked;
- pthread_mutex_t* mut;
+ #ifdef WIN32
+ #else //Linux
+ pthread_mutex_t* mut;
+ #endif
};
static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
|