PR 9812
[binutils-gdb.git] / gold / gold-threads.h
index 45f18ad2c5c0ffbd0447133c31b9ec92368883bf..c901e42e50e3ff1e5f07b02e650350e9ec92b8ea 100644 (file)
@@ -1,6 +1,6 @@
 // gold-threads.h -- thread support for gold  -*- C++ -*-
 
-// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -107,6 +107,29 @@ class Hold_lock
   Lock& lock_;
 };
 
+class Hold_optional_lock
+{
+ public:
+  Hold_optional_lock(Lock* lock)
+    : lock_(lock)
+  {
+    if (this->lock_ != NULL)
+      this->lock_->acquire();
+  }
+
+  ~Hold_optional_lock()
+  {
+    if (this->lock_ != NULL)
+      this->lock_->release();
+  }
+
+ private:
+  Hold_optional_lock(const Hold_optional_lock&);
+  Hold_optional_lock& operator=(const Hold_optional_lock&);
+
+  Lock* lock_;
+};
+
 // The interface for the implementation of a condition variable.
 
 class Condvar_impl