summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/Mutex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceUtil/Mutex.cpp')
-rw-r--r--cpp/src/IceUtil/Mutex.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/cpp/src/IceUtil/Mutex.cpp b/cpp/src/IceUtil/Mutex.cpp
new file mode 100644
index 00000000000..32e1036a730
--- /dev/null
+++ b/cpp/src/IceUtil/Mutex.cpp
@@ -0,0 +1,30 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <IceUtil/Mutex.h>
+#include <IceUtil/Exception.h>
+
+#ifdef _WIN32
+
+bool
+IceUtil::Mutex::tryLock() const
+{
+ if(!TryEnterCriticalSection(&_mutex))
+ {
+ return false;
+ }
+ if(_mutex.RecursionCount > 1)
+ {
+ LeaveCriticalSection(&_mutex);
+ throw ThreadLockedException(__FILE__, __LINE__);
+ }
+ return true;
+}
+
+#endif