123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #include "UserTypes.h"
- #include <AzCore/std/parallel/containers/concurrent_fixed_unordered_set.h>
- #include <AzCore/std/parallel/containers/concurrent_fixed_unordered_map.h>
- #include <AzCore/std/parallel/containers/concurrent_unordered_map.h>
- #include <AzCore/std/parallel/containers/concurrent_unordered_set.h>
- #include <AzCore/std/parallel/containers/concurrent_vector.h>
- #include <AzCore/std/parallel/thread.h>
- #include <AzCore/std/functional.h>
- #include <AzCore/std/smart_ptr/unique_ptr.h>
- namespace UnitTest
- {
- using namespace AZStd;
- using namespace UnitTestInternal;
- template<typename Set>
- class ConcurrentUnorderedSetTestBase
- : public LeakDetectionFixture
- {
- public:
- void run()
- {
- Set set;
- //insert
- AZ_TEST_ASSERT(set.empty());
- AZ_TEST_ASSERT(set.size() == 0);
- AZ_TEST_ASSERT(set.insert(10));
- AZ_TEST_ASSERT(!set.empty());
- AZ_TEST_ASSERT(set.size() == 1);
- AZ_TEST_ASSERT(set.insert(20));
- AZ_TEST_ASSERT(set.size() == 2);
- AZ_TEST_ASSERT(set.insert(30));
- AZ_TEST_ASSERT(set.size() == 3);
- AZ_TEST_ASSERT(!set.insert(20)); //not multiset
- AZ_TEST_ASSERT(set.size() == 3);
- //find
- AZ_TEST_ASSERT(set.find(10));
- AZ_TEST_ASSERT(!set.find(40));
- //erase
- AZ_TEST_ASSERT(set.erase(10) == 1);
- AZ_TEST_ASSERT(set.size() == 2);
- AZ_TEST_ASSERT(set.erase(10) == 0);
- AZ_TEST_ASSERT(set.size() == 2);
- AZ_TEST_ASSERT(set.erase(100) == 0);
- AZ_TEST_ASSERT(set.size() == 2);
- //erase_one
- AZ_TEST_ASSERT(set.erase_one(20));
- AZ_TEST_ASSERT(set.size() == 1);
- AZ_TEST_ASSERT(set.erase_one(30));
- AZ_TEST_ASSERT(set.size() == 0);
- AZ_TEST_ASSERT(set.empty());
- //clear
- set.insert(10);
- AZ_TEST_ASSERT(!set.empty());
- set.clear();
- AZ_TEST_ASSERT(set.empty());
- AZ_TEST_ASSERT(set.erase(10) == 0);
- //assignment
- set.insert(10);
- set.insert(20);
- set.insert(30);
- Set set2(set);
- AZ_TEST_ASSERT(set2.size() == 3);
- AZ_TEST_ASSERT(set2.find(20));
- Set set3;
- set3 = set;
- AZ_TEST_ASSERT(set3.size() == 3);
- AZ_TEST_ASSERT(set3.find(20));
- set.erase(10);
- AZ_TEST_ASSERT(set.size() == 2);
- set.swap(set3);
- AZ_TEST_ASSERT(set.size() == 3);
- AZ_TEST_ASSERT(set3.size() == 2);
- {
- m_failures = 0;
- AZStd::thread thread0(AZStd::bind(&ConcurrentUnorderedSetTestBase::InsertErase, this, 0));
- AZStd::thread thread1(AZStd::bind(&ConcurrentUnorderedSetTestBase::InsertErase, this, 1));
- AZStd::thread thread2(AZStd::bind(&ConcurrentUnorderedSetTestBase::InsertErase, this, 2));
- AZStd::thread thread3(AZStd::bind(&ConcurrentUnorderedSetTestBase::InsertErase, this, 3));
- thread0.join();
- thread1.join();
- thread2.join();
- thread3.join();
- AZ_TEST_ASSERT(m_failures == 0);
- AZ_TEST_ASSERT(m_set.empty());
- }
- m_set = Set(); // clear memory
- }
- private:
- #ifdef _DEBUG
- static const int NUM_ITERATIONS = 1;
- #else
- static const int NUM_ITERATIONS = 200;
- #endif
- static const int NUM_VALUES = 500;
- void InsertErase(int id)
- {
- for (int iter = 0; iter < NUM_ITERATIONS; ++iter)
- {
- //insert
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (!m_set.insert(id * NUM_VALUES + i))
- {
- ++m_failures;
- }
- }
- //find
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (!m_set.find(id * NUM_VALUES + i))
- {
- ++m_failures;
- }
- }
- //erase
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (m_set.erase(id * NUM_VALUES + i) != 1)
- {
- ++m_failures;
- }
- }
- }
- }
- Set m_set;
- atomic<int> m_failures;
- };
- typedef ConcurrentUnorderedSetTestBase<concurrent_unordered_set<int> > ConcurrentUnorderedSetTest;
- typedef ConcurrentUnorderedSetTestBase<concurrent_fixed_unordered_set<int, 1543, 2100> > ConcurrentFixedUnorderedSetTest;
- TEST_F(ConcurrentUnorderedSetTest, Test)
- {
- run();
- }
- TEST_F(ConcurrentFixedUnorderedSetTest, Test)
- {
- run();
- }
- template<typename Set>
- class ConcurrentUnorderedMultiSetTestBase
- : public LeakDetectionFixture
- {
- public:
- void run()
- {
- Set set;
- //insert
- AZ_TEST_ASSERT(set.empty());
- AZ_TEST_ASSERT(set.size() == 0);
- AZ_TEST_ASSERT(set.insert(10));
- AZ_TEST_ASSERT(!set.empty());
- AZ_TEST_ASSERT(set.size() == 1);
- AZ_TEST_ASSERT(set.insert(20));
- AZ_TEST_ASSERT(set.size() == 2);
- AZ_TEST_ASSERT(set.insert(20)); //multiset
- AZ_TEST_ASSERT(set.size() == 3);
- AZ_TEST_ASSERT(set.insert(30));
- AZ_TEST_ASSERT(set.insert(30));
- AZ_TEST_ASSERT(set.insert(30));
- AZ_TEST_ASSERT(set.size() == 6);
- //find
- AZ_TEST_ASSERT(set.find(10));
- AZ_TEST_ASSERT(set.find(20));
- AZ_TEST_ASSERT(!set.find(40));
- //erase
- AZ_TEST_ASSERT(set.erase(10) == 1);
- AZ_TEST_ASSERT(set.size() == 5);
- AZ_TEST_ASSERT(set.erase(10) == 0);
- AZ_TEST_ASSERT(set.size() == 5);
- AZ_TEST_ASSERT(set.erase(100) == 0);
- AZ_TEST_ASSERT(set.size() == 5);
- AZ_TEST_ASSERT(set.erase(20) == 2);
- AZ_TEST_ASSERT(set.size() == 3);
- //erase_one
- AZ_TEST_ASSERT(set.erase_one(30));
- AZ_TEST_ASSERT(set.size() == 2);
- AZ_TEST_ASSERT(set.erase(30) == 2);
- AZ_TEST_ASSERT(set.size() == 0);
- AZ_TEST_ASSERT(set.empty());
- //clear
- set.insert(10);
- AZ_TEST_ASSERT(!set.empty());
- set.clear();
- AZ_TEST_ASSERT(set.empty());
- AZ_TEST_ASSERT(set.erase(10) == 0);
- //assignment
- set.insert(10);
- set.insert(20);
- set.insert(30);
- Set set2(set);
- AZ_TEST_ASSERT(set2.size() == 3);
- AZ_TEST_ASSERT(set2.find(20));
- Set set3;
- set3 = set;
- AZ_TEST_ASSERT(set3.size() == 3);
- AZ_TEST_ASSERT(set3.find(20));
- set.erase(10);
- AZ_TEST_ASSERT(set.size() == 2);
- set.swap(set3);
- AZ_TEST_ASSERT(set.size() == 3);
- AZ_TEST_ASSERT(set3.size() == 2);
- {
- m_failures = 0;
- AZStd::thread thread0(AZStd::bind(&ConcurrentUnorderedMultiSetTestBase::InsertErase, this));
- AZStd::thread thread1(AZStd::bind(&ConcurrentUnorderedMultiSetTestBase::InsertErase, this));
- AZStd::thread thread2(AZStd::bind(&ConcurrentUnorderedMultiSetTestBase::InsertErase, this));
- AZStd::thread thread3(AZStd::bind(&ConcurrentUnorderedMultiSetTestBase::InsertErase, this));
- thread0.join();
- thread1.join();
- thread2.join();
- thread3.join();
- AZ_TEST_ASSERT(m_failures == 0);
- AZ_TEST_ASSERT(m_set.empty());
- }
- m_set = Set(); // clear memory
- }
- private:
- #ifdef _DEBUG
- static const int NUM_ITERATIONS = 1;
- #else
- static const int NUM_ITERATIONS = 200;
- #endif
- static const int NUM_VALUES = 500;
- void InsertErase()
- {
- for (int iter = 0; iter < NUM_ITERATIONS; ++iter)
- {
- //insert
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (!m_set.insert(i))
- {
- ++m_failures;
- }
- }
- //find
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (!m_set.find(i))
- {
- ++m_failures;
- }
- }
- //erase
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (!m_set.erase_one(i))
- {
- ++m_failures;
- }
- }
- }
- }
- Set m_set;
- atomic<int> m_failures;
- };
- typedef ConcurrentUnorderedMultiSetTestBase<concurrent_unordered_multiset<int> > ConcurrentUnorderedMultiSetTest;
- typedef ConcurrentUnorderedMultiSetTestBase<concurrent_fixed_unordered_multiset<int, 1543, 2100> > ConcurrentFixedUnorderedMultiSetTest;
- TEST_F(ConcurrentUnorderedMultiSetTest, Test)
- {
- run();
- }
- TEST_F(ConcurrentFixedUnorderedMultiSetTest, Test)
- {
- run();
- }
- template<typename Map>
- class ConcurrentUnorderedMapTestBase
- : public LeakDetectionFixture
- {
- public:
- void run()
- {
- Map map;
- //insert
- AZ_TEST_ASSERT(map.empty());
- AZ_TEST_ASSERT(map.size() == 0);
- AZ_TEST_ASSERT(map.insert(AZStd::make_pair(10, 11)));
- AZ_TEST_ASSERT(!map.empty());
- AZ_TEST_ASSERT(map.size() == 1);
- AZ_TEST_ASSERT(map.insert(AZStd::make_pair(20, 21)));
- AZ_TEST_ASSERT(map.size() == 2);
- AZ_TEST_ASSERT(map.insert(AZStd::make_pair(30, 31)));
- AZ_TEST_ASSERT(map.size() == 3);
- AZ_TEST_ASSERT(!map.insert(AZStd::make_pair(20, 22))); //not multimap
- AZ_TEST_ASSERT(map.size() == 3);
- //find
- AZ_TEST_ASSERT(map.find(10));
- AZ_TEST_ASSERT(!map.find(40));
- int result = 0;
- AZ_TEST_ASSERT(map.find(10, &result));
- AZ_TEST_ASSERT(result == 11);
- //erase
- AZ_TEST_ASSERT(map.erase(10) == 1);
- AZ_TEST_ASSERT(map.size() == 2);
- AZ_TEST_ASSERT(map.erase(10) == 0);
- AZ_TEST_ASSERT(map.size() == 2);
- AZ_TEST_ASSERT(map.erase(100) == 0);
- AZ_TEST_ASSERT(map.size() == 2);
- //erase_one
- AZ_TEST_ASSERT(map.erase_one(20));
- AZ_TEST_ASSERT(map.size() == 1);
- AZ_TEST_ASSERT(map.erase_one(30));
- AZ_TEST_ASSERT(map.size() == 0);
- AZ_TEST_ASSERT(map.empty());
- //clear
- map.insert(10);
- AZ_TEST_ASSERT(!map.empty());
- map.clear();
- AZ_TEST_ASSERT(map.empty());
- AZ_TEST_ASSERT(map.erase(10) == 0);
- //assignment
- map.insert(AZStd::make_pair(10, 11));
- map.insert(AZStd::make_pair(20, 21));
- map.insert(AZStd::make_pair(30, 31));
- Map map2(map);
- AZ_TEST_ASSERT(map2.size() == 3);
- AZ_TEST_ASSERT(map2.find(20));
- Map map3;
- map3 = map;
- AZ_TEST_ASSERT(map3.size() == 3);
- AZ_TEST_ASSERT(map3.find(20));
- map.erase(10);
- AZ_TEST_ASSERT(map.size() == 2);
- map.swap(map3);
- AZ_TEST_ASSERT(map.size() == 3);
- AZ_TEST_ASSERT(map3.size() == 2);
- {
- m_failures = 0;
- AZStd::thread thread0(AZStd::bind(&ConcurrentUnorderedMapTestBase::InsertErase, this, 0));
- AZStd::thread thread1(AZStd::bind(&ConcurrentUnorderedMapTestBase::InsertErase, this, 1));
- AZStd::thread thread2(AZStd::bind(&ConcurrentUnorderedMapTestBase::InsertErase, this, 2));
- AZStd::thread thread3(AZStd::bind(&ConcurrentUnorderedMapTestBase::InsertErase, this, 3));
- thread0.join();
- thread1.join();
- thread2.join();
- thread3.join();
- AZ_TEST_ASSERT(m_failures == 0);
- AZ_TEST_ASSERT(m_map.empty());
- }
- m_map = Map(); // clear memory
- }
- private:
- #ifdef _DEBUG
- static const int NUM_ITERATIONS = 1;
- #else
- static const int NUM_ITERATIONS = 200;
- #endif
- static const int NUM_VALUES = 500;
- void InsertErase(int id)
- {
- for (int iter = 0; iter < NUM_ITERATIONS; ++iter)
- {
- //insert
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (!m_map.insert(AZStd::make_pair(id * NUM_VALUES + i, id * NUM_VALUES + i + 1)))
- {
- ++m_failures;
- }
- }
- //find
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- int result = 0;
- if (!m_map.find(id * NUM_VALUES + i, &result))
- {
- ++m_failures;
- }
- if (result != id * NUM_VALUES + i + 1)
- {
- ++m_failures;
- }
- }
- //erase
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (m_map.erase(id * NUM_VALUES + i) != 1)
- {
- ++m_failures;
- }
- }
- }
- }
- Map m_map;
- atomic<int> m_failures;
- };
- typedef ConcurrentUnorderedMapTestBase<concurrent_unordered_map<int, int> > ConcurrentUnorderedMapTest;
- typedef ConcurrentUnorderedMapTestBase<concurrent_fixed_unordered_map<int, int, 1543, 2100> > ConcurrentFixedUnorderedMapTest;
- TEST_F(ConcurrentUnorderedMapTest, Test)
- {
- run();
- }
- TEST_F(ConcurrentFixedUnorderedMapTest, Test)
- {
- run();
- }
- template<typename Map>
- class ConcurrentUnorderedMultiMapTestBase
- : public LeakDetectionFixture
- {
- public:
- void run()
- {
- Map map;
- //insert
- AZ_TEST_ASSERT(map.empty());
- AZ_TEST_ASSERT(map.size() == 0);
- AZ_TEST_ASSERT(map.insert(AZStd::make_pair(10, 11)));
- AZ_TEST_ASSERT(!map.empty());
- AZ_TEST_ASSERT(map.size() == 1);
- AZ_TEST_ASSERT(map.insert(AZStd::make_pair(20, 21)));
- AZ_TEST_ASSERT(map.size() == 2);
- AZ_TEST_ASSERT(map.insert(AZStd::make_pair(20, 22))); //multimap
- AZ_TEST_ASSERT(map.size() == 3);
- AZ_TEST_ASSERT(map.insert(AZStd::make_pair(30, 31)));
- AZ_TEST_ASSERT(map.insert(AZStd::make_pair(30, 32)));
- AZ_TEST_ASSERT(map.insert(AZStd::make_pair(30, 33)));
- AZ_TEST_ASSERT(map.size() == 6);
- //find
- AZ_TEST_ASSERT(map.find(10));
- AZ_TEST_ASSERT(map.find(20));
- AZ_TEST_ASSERT(!map.find(40));
- int result = 0;
- AZ_TEST_ASSERT(map.find(10, &result));
- AZ_TEST_ASSERT(result == 11);
- //erase
- AZ_TEST_ASSERT(map.erase(10) == 1);
- AZ_TEST_ASSERT(map.size() == 5);
- AZ_TEST_ASSERT(map.erase(10) == 0);
- AZ_TEST_ASSERT(map.size() == 5);
- AZ_TEST_ASSERT(map.erase(100) == 0);
- AZ_TEST_ASSERT(map.size() == 5);
- AZ_TEST_ASSERT(map.erase(20) == 2);
- AZ_TEST_ASSERT(map.size() == 3);
- //erase_one
- AZ_TEST_ASSERT(map.erase_one(30));
- AZ_TEST_ASSERT(map.size() == 2);
- AZ_TEST_ASSERT(map.erase(30) == 2);
- AZ_TEST_ASSERT(map.size() == 0);
- AZ_TEST_ASSERT(map.empty());
- //clear
- map.insert(10);
- AZ_TEST_ASSERT(!map.empty());
- map.clear();
- AZ_TEST_ASSERT(map.empty());
- AZ_TEST_ASSERT(map.erase(10) == 0);
- //assignment
- map.insert(10);
- map.insert(20);
- map.insert(30);
- Map map2(map);
- AZ_TEST_ASSERT(map2.size() == 3);
- AZ_TEST_ASSERT(map2.find(20));
- Map map3;
- map3 = map;
- AZ_TEST_ASSERT(map3.size() == 3);
- AZ_TEST_ASSERT(map3.find(20));
- map.erase(10);
- AZ_TEST_ASSERT(map.size() == 2);
- map.swap(map3);
- AZ_TEST_ASSERT(map.size() == 3);
- AZ_TEST_ASSERT(map3.size() == 2);
- {
- m_failures = 0;
- AZStd::thread thread0(AZStd::bind(&ConcurrentUnorderedMultiMapTestBase::InsertErase, this));
- AZStd::thread thread1(AZStd::bind(&ConcurrentUnorderedMultiMapTestBase::InsertErase, this));
- AZStd::thread thread2(AZStd::bind(&ConcurrentUnorderedMultiMapTestBase::InsertErase, this));
- AZStd::thread thread3(AZStd::bind(&ConcurrentUnorderedMultiMapTestBase::InsertErase, this));
- thread0.join();
- thread1.join();
- thread2.join();
- thread3.join();
- AZ_TEST_ASSERT(m_failures == 0);
- AZ_TEST_ASSERT(m_map.empty());
- }
- Map dummy;
- m_map.swap(dummy); // clear memory
- }
- private:
- #ifdef _DEBUG
- static const int NUM_ITERATIONS = 1;
- #else
- static const int NUM_ITERATIONS = 200;
- #endif
- static const int NUM_VALUES = 500;
- void InsertErase()
- {
- for (int iter = 0; iter < NUM_ITERATIONS; ++iter)
- {
- //insert
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (!m_map.insert(AZStd::make_pair(i, i + 1)))
- {
- ++m_failures;
- }
- }
- //find
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- int result = 0;
- if (!m_map.find(i, &result))
- {
- ++m_failures;
- }
- if (result != i + 1)
- {
- ++m_failures;
- }
- }
- //erase
- for (int i = 0; i < NUM_VALUES; ++i)
- {
- if (!m_map.erase_one(i))
- {
- ++m_failures;
- }
- }
- }
- }
- Map m_map;
- atomic<int> m_failures;
- };
- typedef ConcurrentUnorderedMultiMapTestBase<concurrent_unordered_multimap<int, int> > ConcurrentUnorderedMultiMapTest;
- typedef ConcurrentUnorderedMultiMapTestBase<concurrent_fixed_unordered_multimap<int, int, 1543, 2100> > ConcurrentFixedUnorderedMultiMapTest;
- TEST_F(ConcurrentUnorderedMultiMapTest, Test)
- {
- run();
- }
-
- TEST_F(ConcurrentFixedUnorderedMultiMapTest, Test)
- {
- run();
- }
- class ConcurrentVectorTest
- : public LeakDetectionFixture
- {
- public:
- void run()
- {
- //
- //single threaded functionality tests
- //
- concurrent_vector<int> testVector;
- AZ_TEST_ASSERT(testVector.empty());
- AZ_TEST_ASSERT(testVector.size() == 0);
- testVector.push_back(10);
- AZ_TEST_ASSERT(!testVector.empty());
- AZ_TEST_ASSERT(testVector.size() == 1);
- AZ_TEST_ASSERT(testVector[0] == 10);
- testVector[0] = 20;
- AZ_TEST_ASSERT(testVector[0] == 20);
- testVector.clear();
- AZ_TEST_ASSERT(testVector.empty());
- AZ_TEST_ASSERT(testVector.size() == 0);
- for (int i = 0; i < 100; ++i)
- {
- testVector.push_back(i + 1000);
- }
- AZ_TEST_ASSERT(testVector.size() == 100);
- for (int i = 0; i < 100; ++i)
- {
- AZ_TEST_ASSERT(testVector[i] == i + 1000);
- }
- //
- //multithread tests
- //
- {
- AZStd::thread thread0(AZStd::bind(&ConcurrentVectorTest::Push, this, 0));
- AZStd::thread thread1(AZStd::bind(&ConcurrentVectorTest::Push, this, 1));
- AZStd::thread thread2(AZStd::bind(&ConcurrentVectorTest::Push, this, 2));
- AZStd::thread thread3(AZStd::bind(&ConcurrentVectorTest::Push, this, 3));
- thread0.join();
- thread1.join();
- thread2.join();
- thread3.join();
- //verify vector contains the right values in the expected order
- AZ_TEST_ASSERT(m_vector.size() == 4 * NUM_ITERATIONS);
- int nextValue[4];
- for (int i = 0; i < 4; ++i)
- {
- nextValue[i] = i * NUM_ITERATIONS;
- }
- for (unsigned int vecIndex = 0; vecIndex < m_vector.size(); ++vecIndex)
- {
- int value = m_vector[vecIndex];
- bool isFound = false;
- for (int i = 0; i < 4; ++i)
- {
- if (nextValue[i] == value)
- {
- isFound = true;
- ++nextValue[i];
- break;
- }
- }
- AZ_TEST_ASSERT(isFound);
- }
- }
- }
- private:
- #if defined(_DEBUG)
- static const int NUM_ITERATIONS = 10000;
- #else
- static const int NUM_ITERATIONS = 500000;
- #endif
- void Push(int threadIndex)
- {
- for (int i = 0; i < NUM_ITERATIONS; ++i)
- {
- m_vector.push_back(threadIndex * NUM_ITERATIONS + i);
- }
- }
- concurrent_vector<int> m_vector;
- };
- TEST_F(ConcurrentVectorTest, Test)
- {
- run();
- }
- }
|