#include "AtomicAccumulate.h" #include #include #include #include #include /* Test code for AtomicAccumulate.h. Don't include this file in production * software. * g++ -Wall -O4 -lpthread -ggdb AtomicAccumulate.C */ void theadTestHelper(AtomicAccumulate< int > *aa, int count) { for (int i = 0; i < count; i++) aa->emplace(i); } void threadTest(int count) { AtomicAccumulate< int > aa; new std::thread(theadTestHelper, &aa, count); int next = 0; std::vector< int > counts; while (next < count) { int subCount = 0; aa.takeFIFO([&next, &subCount](int remote) { subCount++; assert(remote == next); next++; }); counts.push_back(subCount); } std::cout<<"threadTest("< strings; std::string a1 = "Abc"; std::string a2 = "def"; std::string a3 = "ghi"; std::string a4 = "jk!"; // They should come out in the same order you put them in. strings.emplace(a1); strings.emplace(a2); strings.emplace(a3); strings.emplace(a4); std::cout<<"FIFO: "; strings.takeFIFO(dump); std::cout< as; as.emplace("1a"); as.emplace("1b"); as.emplace("1c"); as.takeFIFO([](HasDestructor const &hd) { std::cout<<"as.takeFIFO() ➡ "<