CHECK() is not thread safe so return the result in *failed.
| 154 | |
| 155 | // CHECK() is not thread safe so return the result in *failed. |
| 156 | void ProducerThread(InternalQueue<IntNode>* queue, int num_inserts, |
| 157 | vector<IntNode>* nodes, AtomicInt32* counter, bool* failed) { |
| 158 | for (int i = 0; i < num_inserts && !*failed; ++i) { |
| 159 | // Get the next index to queue. |
| 160 | int32_t value = counter->Add(1) - 1; |
| 161 | nodes->at(value).value = value; |
| 162 | queue->Enqueue(&nodes->at(value)); |
| 163 | if (i % VALIDATE_INTERVAL == 0) { |
| 164 | if (!queue->Validate()) *failed = true; |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | void ConsumerThread(InternalQueue<IntNode>* queue, int num_consumes, int delta, |
| 170 | vector<int>* results, bool* failed) { |