aboutsummaryrefslogtreecommitdiff
path: root/gold/workqueue.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2006-09-21 22:13:18 +0000
committerIan Lance Taylor <iant@google.com>2006-09-21 22:13:18 +0000
commita2fb1b05e4af3fac54faac6c07a4717f2cb34aae (patch)
treecab19eb8c3abe76aee65d684dcceee884ed59c61 /gold/workqueue.h
parent5ffff7c1d1d2db595e4c23a8c388d3a51d5bb357 (diff)
downloadgdb-a2fb1b05e4af3fac54faac6c07a4717f2cb34aae.zip
gdb-a2fb1b05e4af3fac54faac6c07a4717f2cb34aae.tar.gz
gdb-a2fb1b05e4af3fac54faac6c07a4717f2cb34aae.tar.bz2
New drop, with first cut of section layout code.
Diffstat (limited to 'gold/workqueue.h')
-rw-r--r--gold/workqueue.h38
1 files changed, 30 insertions, 8 deletions
diff --git a/gold/workqueue.h b/gold/workqueue.h
index 5949cf5..a97d86d 100644
--- a/gold/workqueue.h
+++ b/gold/workqueue.h
@@ -146,6 +146,27 @@ class Task_block_token
Workqueue* workqueue_;
};
+// An object which implements an RAII lock for any object which
+// supports lock and unlock methods.
+
+template<typename Obj>
+class Task_lock_obj
+{
+ public:
+ Task_lock_obj(Obj& obj)
+ : obj_(obj)
+ { this->obj_.lock(); }
+
+ ~Task_lock_obj()
+ { this->obj_.unlock(); }
+
+ private:
+ Task_lock_obj(const Task_lock_obj&);
+ Task_lock_obj& operator=(const Task_lock_obj&);
+
+ Obj& obj_;
+};
+
// An abstract class used to lock Task_tokens using RAII. A typical
// implementation would simply have a set of members of type
// Task_read_token, Task_write_token, and Task_block_token.
@@ -209,21 +230,22 @@ class Task_locker_block : public Task_locker
Task_block_token block_token_;
};
-// A version of Task_locker which may be used to hold a lock on a
-// File_read.
+// A version of Task_locker which may be used to hold a lock on any
+// object which supports lock() and unlock() methods.
-class Task_locker_file : public Task_locker
+template<typename Obj>
+class Task_locker_obj : public Task_locker
{
public:
- Task_locker_file(File_read& file)
- : file_lock_(file)
+ Task_locker_obj(Obj& obj)
+ : obj_lock_(obj)
{ }
private:
- Task_locker_file(const Task_locker_file&);
- Task_locker_file& operator=(const Task_locker_file&);
+ Task_locker_obj(const Task_locker_obj&);
+ Task_locker_obj& operator=(const Task_locker_obj&);
- File_read_lock file_lock_;
+ Task_lock_obj<Obj> obj_lock_;
};
// The superclass for tasks to be placed on the workqueue. Each