Testing Spices::ObjectPool::ThreadAllocAfterDeAlloc.
230 {
231
233
234 std::vector<Object*> objects1;
235 std::vector<Object*> objects2;
236
237 objects1.resize(n);
238 objects2.resize(n);
239
240 auto internalThreadNew = [&](std::vector<Object*>& objects) {
241 for (int i = 0; i < n; i++)
242 {
243 objects[i] = m_ObjectPool->ThreadNew();
244 }
245 };
246
247 auto internalThreadDelete = [&](std::vector<Object*>& objects) {
248 for (int i = 0; i < n; i++)
249 {
250 m_ObjectPool->ThreadDelete(objects[i]);
251 }
252 };
253
254 for (int k = 0; k < 2; k++)
255 {
256 std::thread t1([&]() {
257 for (int j = 0; j < 2; j++)
258 {
259 internalThreadNew(objects1);
260 internalThreadDelete(objects1);
261 }
262 });
263
264 std::thread t2([&]() {
265 for (int j = 0; j < 2; j++)
266 {
267 internalThreadNew(objects2);
268 internalThreadDelete(objects2);
269 }
270 });
271
272 t1.join();
273 t2.join();
274 }
275 }
#define SPICESTEST_PROFILE_FUNCTION()