MCPcopy Create free account
hub / github.com/apple/foundationdb / QueueTestThreadState

Class QueueTestThreadState

flow/Net2.actor.cpp:2170–2187  ·  view source on GitHub ↗

A helper struct used by queueing tests which use multiple threads.

Source from the content-addressed store, hash-verified

2168
2169// A helper struct used by queueing tests which use multiple threads.
2170struct QueueTestThreadState {
2171 QueueTestThreadState(int threadId, int toProduce) : threadId(threadId), toProduce(toProduce) {}
2172 int threadId;
2173 THREAD_HANDLE handle;
2174 int toProduce;
2175 int produced = 0;
2176 Promise<Void> doneProducing;
2177 int consumed = 0;
2178
2179 static int valueToThreadId(int value) { return value >> 20; }
2180 int elementValue(int index) { return index + (threadId << 20); }
2181 int nextProduced() { return elementValue(produced++); }
2182 int nextConsumed() { return elementValue(consumed++); }
2183 void checkDone() {
2184 ASSERT_EQ(produced, toProduce);
2185 ASSERT_EQ(consumed, produced);
2186 }
2187};
2188
2189TEST_CASE("/flow/Net2/ThreadSafeQueue/Threaded") {
2190 // Uses ThreadSafeQueue from multiple threads. Verifies that all pushed elements are popped, maintaining the

Callers 1

Net2.actor.cppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected