summaryrefslogtreecommitdiff
path: root/cppe/src/IceE/StaticMutex.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2005-07-05 11:09:55 +0000
committerDwayne Boone <dwayne@zeroc.com>2005-07-05 11:09:55 +0000
commit9b8cc712d4a41d71840416776bc94ee8485bb9b3 (patch)
tree7d467fdd6a66bc2b5878d82070d45adbd5c20414 /cppe/src/IceE/StaticMutex.cpp
parentcleaning the cache method out of ReferenceFactory (diff)
downloadice-9b8cc712d4a41d71840416776bc94ee8485bb9b3.tar.bz2
ice-9b8cc712d4a41d71840416776bc94ee8485bb9b3.tar.xz
ice-9b8cc712d4a41d71840416776bc94ee8485bb9b3.zip
Changed Ice to IceE EVERYWHERE!!!
Diffstat (limited to 'cppe/src/IceE/StaticMutex.cpp')
-rw-r--r--cppe/src/IceE/StaticMutex.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/cppe/src/IceE/StaticMutex.cpp b/cppe/src/IceE/StaticMutex.cpp
new file mode 100644
index 00000000000..1158237d7f4
--- /dev/null
+++ b/cppe/src/IceE/StaticMutex.cpp
@@ -0,0 +1,42 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICEE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <IceE/StaticMutex.h>
+
+#ifdef _WIN32
+void IceE::StaticMutex::initialize() const
+{
+ //
+ // First we create the new critical section
+ //
+ CRITICAL_SECTION* newCriticalSection = new CRITICAL_SECTION;
+ InitializeCriticalSection(newCriticalSection);
+
+ //
+ // Then assign it to _mutex
+ // Note that Windows performs a full memory barrier before the assignment;
+ // this ensures we write the initialized critical section before we write _mutex.
+ //
+ if(InterlockedCompareExchangePointer(reinterpret_cast<void**>(&_mutex), newCriticalSection, 0) != 0)
+ {
+ //
+ // Another thread was doing the same thing
+ //
+ DeleteCriticalSection(newCriticalSection);
+ delete newCriticalSection;
+ }
+
+ //
+ // This implementation does not attempt to clean up the initialized and assigned critical sections:
+ // they leak
+ //
+}
+#endif
+
+IceE::StaticMutex IceE::globalMutex = ICEE_STATIC_MUTEX_INITIALIZER;