| 61 | }; |
| 62 | |
| 63 | TEST_FIX(ThreadPool, BasicAPI) |
| 64 | { |
| 65 | // Construct the vector of results from the work items. |
| 66 | const U32 numItems = 100; |
| 67 | Vector<U32> results(__FILE__, __LINE__); |
| 68 | results.setSize(numItems); |
| 69 | for (U32 i = 0; i < numItems; i++) |
| 70 | results[i] = U32(-1); |
| 71 | |
| 72 | // Launch the work items. |
| 73 | ThreadPool* pool = &ThreadPool::GLOBAL(); |
| 74 | for (U32 i = 0; i < numItems; i++) |
| 75 | { |
| 76 | ThreadSafeRef<TestItem> item(new TestItem(i, results)); |
| 77 | pool->queueWorkItem(item); |
| 78 | } |
| 79 | |
| 80 | pool->waitForAllItems(); |
| 81 | |
| 82 | // Verify. |
| 83 | for (U32 i = 0; i < numItems; i++) |
| 84 | EXPECT_EQ(results[i], i) << "result mismatch"; |
| 85 | results.clear(); |
| 86 | } |
| 87 | |
| 88 | TEST_FIX(ThreadPool, Asynchronous) |
| 89 | { |
nothing calls this directly
no test coverage detected