int main(int argc, char **argv) { std::cout << "Hello!" << std::endl; pthread_mutex_init(&lock, NULL); pthread_create(&thread1, NULL, read, NULL); for(int i = 0; i < 100; i++) pthread_create(&thread2, NULL, add, (void*)i); pthread_join(thread2, NULL); pthread_join(thread1, NULL); list.pushBack(5); list.pushBack(10); list.pushBack(4); list.pushBack(12); //Attenzione: pushFront list.pushFront(9); ConcurrentList<int>::cIterator iter; for(iter = list.begin(); iter != list.end(); iter++) { int i = *iter; std::cout << i << std::endl; } std::cout << "Eseguo la cancellazione singola (10)\n"; iter = list.begin(); iter++; iter++; iter = list.erase(iter); for(iter = list.begin(); iter != list.end(); iter++) { int i = *iter; std::cout << i << std::endl; } std::cout << "Eseguo le cancellazioni multiple (9 - 5) \n"; iter = list.begin(); iter++; iter++; iter = list.erase(list.begin(), iter); for(iter = list.begin(); iter != list.end(); iter++) { int i = *iter; std::cout << i << std::endl; } return 0; }
TEST(Concurrent, ConcurrentList) { const int numElem = 100; const int elemVal = 1; ConcurrentList<int> List; auto results = RaceTest<int*>( [&]() -> int* { for (int i = 0; i < numElem; i++) List.push_front(elemVal); return nullptr; } ); size_t ListLen = std::distance(List.begin(), List.end()); // Check that all of the values are initialized properly. for (auto A : List) { EXPECT_EQ(elemVal, A); } // Check that the length of the list is correct. EXPECT_EQ(ListLen, results.size() * numElem); }