* libbfd-in.h (_bfd_norelocs_get_reloc_upper_bound): Don't define,
[binutils.git] / gold / gold-threads.h
blobe2a8388ac1361b3baa8050affcb430794095e275
1 // gold-threads.h -- thread support for gold -*- C++ -*-
3 // gold can be configured to support threads. If threads are
4 // supported, the user can specify at runtime whether or not to
5 // support them. This provides an interface to manage locking
6 // accordingly.
8 // Lock
9 // A simple lock class.
11 #ifndef GOLD_THREADS_H
12 #define GOLD_THREADS_H
14 namespace gold
17 class Lock_impl;
18 class Condvar;
20 // A simple lock class.
22 class Lock
24 public:
25 Lock();
26 ~Lock();
28 // Acquire the lock.
29 void
30 acquire();
32 // Release the lock.
33 void
34 release();
36 private:
37 // This class can not be copied.
38 Lock(const Lock&);
39 Lock& operator=(const Lock&);
41 friend class Condvar;
42 Lock_impl*
43 get_impl() const
44 { return this->lock_; }
46 Lock_impl* lock_;
49 // RAII for Lock.
51 class Hold_lock
53 public:
54 Hold_lock(Lock& lock)
55 : lock_(lock)
56 { this->lock_.acquire(); }
58 ~Hold_lock()
59 { this->lock_.release(); }
61 private:
62 // This class can not be copied.
63 Hold_lock(const Hold_lock&);
64 Hold_lock& operator=(const Hold_lock&);
66 Lock& lock_;
69 class Condvar_impl;
71 // A simple condition variable class. It is always associated with a
72 // specific lock.
74 class Condvar
76 public:
77 Condvar(Lock& lock);
78 ~Condvar();
80 // Wait for the condition variable to be signalled. This should
81 // only be called when the lock is held.
82 void
83 wait();
85 // Signal the condition variable. This should only be called when
86 // the lock is held.
87 void
88 signal();
90 private:
91 // This class can not be copied.
92 Condvar(const Condvar&);
93 Condvar& operator=(const Condvar&);
95 Lock& lock_;
96 Condvar_impl* condvar_;
99 } // End namespace gold.
101 #endif // !defined(GOLD_THREADS_H)