| 115 | } |
| 116 | |
| 117 | with_lock (QueueMutex) { |
| 118 | while (MaxQueueSize > 0 && Queue.Size() >= MaxQueueSize && !ShouldTerminate.load()) { |
| 119 | if (!Blocking) { |
| 120 | return false; |
| 121 | } |
| 122 | QueuePopCond.Wait(QueueMutex); |
| 123 | } |
| 124 | |
| 125 | if (ShouldTerminate.load()) { |
| 126 | return false; |
| 127 | } |
| 128 | |
| 129 | Queue.Push(obj); |
| 130 | } |
| 131 | |
| 132 | QueuePushCond.Signal(); |
| 133 |