OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_UTILS_H_ | 5 #ifndef V8_UTILS_H_ |
6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 } | 1633 } |
1634 | 1634 |
1635 private: | 1635 private: |
1636 explicit Iterator(T** entry) : entry_(entry) {} | 1636 explicit Iterator(T** entry) : entry_(entry) {} |
1637 | 1637 |
1638 T** entry_; | 1638 T** entry_; |
1639 | 1639 |
1640 friend class ThreadedList; | 1640 friend class ThreadedList; |
1641 }; | 1641 }; |
1642 | 1642 |
| 1643 class ConstIterator final { |
| 1644 public: |
| 1645 ConstIterator& operator++() { |
| 1646 entry_ = (*entry_)->next(); |
| 1647 return *this; |
| 1648 } |
| 1649 bool operator!=(const ConstIterator& other) { |
| 1650 return entry_ != other.entry_; |
| 1651 } |
| 1652 const T* operator*() const { return *entry_; } |
| 1653 |
| 1654 private: |
| 1655 explicit ConstIterator(T* const* entry) : entry_(entry) {} |
| 1656 |
| 1657 T* const* entry_; |
| 1658 |
| 1659 friend class ThreadedList; |
| 1660 }; |
| 1661 |
1643 Iterator begin() { return Iterator(&head_); } | 1662 Iterator begin() { return Iterator(&head_); } |
1644 Iterator end() { return Iterator(tail_); } | 1663 Iterator end() { return Iterator(tail_); } |
1645 | 1664 |
| 1665 ConstIterator begin() const { return ConstIterator(&head_); } |
| 1666 ConstIterator end() const { return ConstIterator(tail_); } |
| 1667 |
1646 void Rewind(Iterator reset_point) { | 1668 void Rewind(Iterator reset_point) { |
1647 tail_ = reset_point.entry_; | 1669 tail_ = reset_point.entry_; |
1648 *tail_ = nullptr; | 1670 *tail_ = nullptr; |
1649 } | 1671 } |
1650 | 1672 |
1651 void MoveTail(ThreadedList<T>* parent, Iterator location) { | 1673 void MoveTail(ThreadedList<T>* parent, Iterator location) { |
1652 if (parent->end() != location) { | 1674 if (parent->end() != location) { |
1653 DCHECK_NULL(*tail_); | 1675 DCHECK_NULL(*tail_); |
1654 *tail_ = *location; | 1676 *tail_ = *location; |
1655 tail_ = parent->tail_; | 1677 tail_ = parent->tail_; |
(...skipping 18 matching lines...) Expand all Loading... |
1674 private: | 1696 private: |
1675 T* head_; | 1697 T* head_; |
1676 T** tail_; | 1698 T** tail_; |
1677 DISALLOW_COPY_AND_ASSIGN(ThreadedList); | 1699 DISALLOW_COPY_AND_ASSIGN(ThreadedList); |
1678 }; | 1700 }; |
1679 | 1701 |
1680 } // namespace internal | 1702 } // namespace internal |
1681 } // namespace v8 | 1703 } // namespace v8 |
1682 | 1704 |
1683 #endif // V8_UTILS_H_ | 1705 #endif // V8_UTILS_H_ |
OLD | NEW |