diff options
| author | Michael Bebenita <[email protected]> | 2010-09-07 18:22:03 -0700 |
|---|---|---|
| committer | Michael Bebenita <[email protected]> | 2010-09-07 18:41:08 -0700 |
| commit | 5375b3916095970bc87675969b2fb00d9bebcfd8 (patch) | |
| tree | 047e13e64c48dfcf26268a2bd125f1645d660301 /src | |
| parent | Change signature of array_list::pop(). (diff) | |
| download | rust-5375b3916095970bc87675969b2fb00d9bebcfd8.tar.xz rust-5375b3916095970bc87675969b2fb00d9bebcfd8.zip | |
Small updates to util classes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rt/util/indexed_list.h | 9 | ||||
| -rw-r--r-- | src/rt/util/synchronized_indexed_list.h | 16 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/rt/util/indexed_list.h b/src/rt/util/indexed_list.h index cd39a0b6..b93945cc 100644 --- a/src/rt/util/indexed_list.h +++ b/src/rt/util/indexed_list.h @@ -10,6 +10,15 @@ public: int32_t list_index; }; +template<typename T> +class indexed_list_element : public indexed_list_object { +public: + T value; + indexed_list_element(T value) : value(value) { + // Nop; + } +}; + /** * An array list of objects that are aware of their position in the list. * Normally, objects in this list should derive from the base class diff --git a/src/rt/util/synchronized_indexed_list.h b/src/rt/util/synchronized_indexed_list.h index ca02f6ef..a7f79a74 100644 --- a/src/rt/util/synchronized_indexed_list.h +++ b/src/rt/util/synchronized_indexed_list.h @@ -7,7 +7,14 @@ template<typename T> class synchronized_indexed_list : public indexed_list<T> { spin_lock _lock; public: - synchronized_indexed_list(memory_region ®ion) : + /** + * Clients can use this global lock that is associated with the list to + * perform more coarse grained locking. Internally, the synchronized list + * doesn'tactually make any use of this lock. + */ + spin_lock global; + + synchronized_indexed_list(memory_region *region) : indexed_list<T>(region) { // Nop. } @@ -20,6 +27,13 @@ public: return index; } + bool pop(T **value) { + _lock.lock(); + bool result = indexed_list<T>::pop(value); + _lock.unlock(); + return result; + } + size_t length() { size_t length = 0; _lock.lock(); |