Remove a white space.
[deliverable/binutils-gdb.git] / gold / gold-threads.h
index bc4595a84df99a54d0b7fdafdf9d6ef7b9eab2e9..9c49b57d071697927f1a40618ccc1bf86fe3a628 100644 (file)
@@ -35,6 +35,7 @@ namespace gold
 {
 
 class Condvar;
+class Initialize_lock_once;
 
 // The interface for the implementation of a Lock.
 
@@ -107,6 +108,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
@@ -167,6 +191,33 @@ class Condvar
   Condvar_impl* condvar_;
 };
 
+// A class used to initialize a lock exactly once, after the options
+// have been read.  This is needed because the implementation of locks
+// depends on whether we've seen the --threads option.  Before the
+// options have been read, we know we are single-threaded, so we can
+// get by without using a lock.  This class should be an instance
+// variable of the class which has a lock which needs to be
+// initialized.
+
+class Initialize_lock
+{
+ public:
+  // The class which uses this will have a pointer to a lock.  This
+  // must be constructed with a pointer to that pointer.
+  Initialize_lock(Lock** pplock);
+
+  // Initialize the lock.  Return true if the lock is now initialized,
+  // false if it is not (because the options have not yet been read).
+  bool
+  initialize();
+
+ private:
+  // A pointer to the lock pointer which must be initialized.
+  Lock** const pplock_;
+  // If needed, a pointer to a pthread_once_t structure.
+  Initialize_lock_once* once_;
+};
+
 } // End namespace gold.
 
 #endif // !defined(GOLD_THREADS_H)
This page took 0.024387 seconds and 4 git commands to generate.