You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/03/18 17:29:52 UTC
cvs commit: ws-axis/c/src/engine SharedObject.cpp SharedObject.h
dicka 2005/03/18 08:29:52
Modified: c/src/engine SharedObject.cpp SharedObject.h
Log:
Use proper synchronization mechanisms on windows.
PR: AXISCPP-559
Submitted by: Tim Bartley
Reviewed by: Adrian Dick
Revision Changes Path
1.13 +4 -5 ws-axis/c/src/engine/SharedObject.cpp
Index: SharedObject.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/engine/SharedObject.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SharedObject.cpp 17 Dec 2004 11:49:45 -0000 1.12
+++ SharedObject.cpp 18 Mar 2005 16:29:52 -0000 1.13
@@ -28,6 +28,7 @@
{
m_bLocked = false;
#ifdef WIN32
+ mut = CreateMutex(NULL, FALSE, NULL);
#else //Linux
mut = new pthread_mutex_t;
pthread_mutex_init (mut, NULL);
@@ -37,6 +38,7 @@
SharedObject::~SharedObject ()
{
#ifdef WIN32
+ CloseHandle(mut);
#else //Linux
pthread_mutex_destroy (mut);
delete mut;
@@ -49,11 +51,7 @@
int SharedObject::lock ()
{
#ifdef WIN32
- while (m_bLocked)
- {
- PLATFORM_SLEEP(0);
- }
-
+ WaitForSingleObject(mut, INFINITE);
#else //Linux
pthread_mutex_lock (mut);
#endif
@@ -64,6 +62,7 @@
int SharedObject::unlock ()
{
#ifdef WIN32
+ ReleaseMutex(mut);
#else //Linux
pthread_mutex_unlock (mut);
#endif
1.17 +2 -0 ws-axis/c/src/engine/SharedObject.h
Index: SharedObject.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/engine/SharedObject.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- SharedObject.h 23 Nov 2004 17:21:03 -0000 1.16
+++ SharedObject.h 18 Mar 2005 16:29:52 -0000 1.17
@@ -24,6 +24,7 @@
#include <axis/GDefine.hpp>
#ifdef WIN32
+#include <windows.h>
#else //Linux
#include "pthread.h"
#endif
@@ -50,6 +51,7 @@
private:
bool m_bLocked;
#ifdef WIN32
+ HANDLE mut;
#else //Linux
pthread_mutex_t *mut;
#endif