| OLD | NEW |
| 1 //===- subzero/src/IceThreading.h - Threading functions ---------*- C++ -*-===// | 1 //===- subzero/src/IceThreading.h - Threading functions ---------*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 /// | 9 /// |
| 10 /// \file | 10 /// \file |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 /// MaxStaticSize, where the queue boundaries are denoted by the Front | 48 /// MaxStaticSize, where the queue boundaries are denoted by the Front |
| 49 /// and Back fields. Front==Back indicates an empty queue. | 49 /// and Back fields. Front==Back indicates an empty queue. |
| 50 template <typename T, size_t MaxStaticSize = 128> | 50 template <typename T, size_t MaxStaticSize = 128> |
| 51 class BoundedProducerConsumerQueue { | 51 class BoundedProducerConsumerQueue { |
| 52 BoundedProducerConsumerQueue() = delete; | 52 BoundedProducerConsumerQueue() = delete; |
| 53 BoundedProducerConsumerQueue(const BoundedProducerConsumerQueue &) = delete; | 53 BoundedProducerConsumerQueue(const BoundedProducerConsumerQueue &) = delete; |
| 54 BoundedProducerConsumerQueue & | 54 BoundedProducerConsumerQueue & |
| 55 operator=(const BoundedProducerConsumerQueue &) = delete; | 55 operator=(const BoundedProducerConsumerQueue &) = delete; |
| 56 | 56 |
| 57 public: | 57 public: |
| 58 BoundedProducerConsumerQueue(bool Sequential, size_t MaxSize = MaxStaticSize) | 58 BoundedProducerConsumerQueue(bool MySequential, |
| 59 : MaxSize(std::min(MaxSize, MaxStaticSize)), Sequential(Sequential) {} | 59 size_t MyMaxSize = MaxStaticSize) |
| 60 : MaxSize(std::min(MyMaxSize, MaxStaticSize)), Sequential(MySequential) {} |
| 60 void blockingPush(T *Item) { | 61 void blockingPush(T *Item) { |
| 61 { | 62 { |
| 62 std::unique_lock<GlobalLockType> L(Lock); | 63 std::unique_lock<GlobalLockType> L(Lock); |
| 63 // If the work queue is already "full", wait for a consumer to | 64 // If the work queue is already "full", wait for a consumer to |
| 64 // grab an element and shrink the queue. | 65 // grab an element and shrink the queue. |
| 65 Shrunk.wait(L, [this] { return size() < MaxSize || Sequential; }); | 66 Shrunk.wait(L, [this] { return size() < MaxSize || Sequential; }); |
| 66 push(Item); | 67 push(Item); |
| 67 } | 68 } |
| 68 GrewOrEnded.notify_one(); | 69 GrewOrEnded.notify_one(); |
| 69 } | 70 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 const uint32_t Sequence; | 200 const uint32_t Sequence; |
| 200 const ItemKind Kind; | 201 const ItemKind Kind; |
| 201 std::unique_ptr<VariableDeclarationList> GlobalInits; | 202 std::unique_ptr<VariableDeclarationList> GlobalInits; |
| 202 std::unique_ptr<Assembler> Function; | 203 std::unique_ptr<Assembler> Function; |
| 203 std::unique_ptr<Cfg> RawFunc; | 204 std::unique_ptr<Cfg> RawFunc; |
| 204 }; | 205 }; |
| 205 | 206 |
| 206 } // end of namespace Ice | 207 } // end of namespace Ice |
| 207 | 208 |
| 208 #endif // SUBZERO_SRC_ICETHREADING_H | 209 #endif // SUBZERO_SRC_ICETHREADING_H |
| OLD | NEW |