int main() { CRunners runners(string("registrants.txt"), string("Lilac BloomsDay"), 7.46, string("Downtown Spokane"), string("Bloomsday")); runners.readRunnersAndSort(); runners.outPutRunnersFile(); return 0; }
void oEvent::setupClubInfoData() { if (tClubDataRevision == dataRevision || Clubs.empty()) return; inthashmap fee(Clubs.size()); inthashmap paid(Clubs.size()); inthashmap runners(Clubs.size()); // Individual fees for (oRunnerList::iterator it = Runners.begin(); it != Runners.end(); ++it) { if (it->isRemoved()) continue; oRunner &r = *it; if (r.Club) { int id = r.Club->Id; ++runners[id]; oDataConstInterface di = r.getDCI(); bool skip = r.Class && r.Class->getClassStatus() == oClass::InvalidRefund; if (!skip) { int cardFee = di.getInt("CardFee"); if (cardFee < 0) cardFee = 0; fee[id] += di.getInt("Fee") + cardFee; } paid[id] += di.getInt("Paid"); } } // Team fees for (oTeamList::iterator it = Teams.begin(); it != Teams.end(); ++it) { if (it->isRemoved()) continue; oTeam &t = *it; if (t.Club) { int id = t.Club->Id; oDataConstInterface di = t.getDCI(); bool skip = t.Class && t.Class->getClassStatus() == oClass::InvalidRefund; if (!skip) { fee[id] += di.getInt("Fee"); } paid[id] += di.getInt("Paid"); } } for (oClubList::iterator it = Clubs.begin(); it != Clubs.end(); ++it) { int id = it->Id; it->tFee = fee[id]; it->tPaid = paid[id]; it->tNumRunners = runners[id]; } tClubDataRevision = dataRevision; }
TEST(libbacktrace, thread_multiple_dump) { // Dump NUM_THREADS simultaneously. std::vector<thread_t> runners(NUM_THREADS); std::vector<dump_thread_t> dumpers(NUM_THREADS); pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); for (size_t i = 0; i < NUM_THREADS; i++) { // Launch the runners, they will spin in hard loops doing nothing. runners[i].tid = 0; runners[i].state = 0; ASSERT_TRUE(pthread_create(&runners[i].threadId, &attr, ThreadMaxRun, &runners[i]) == 0); } // Wait for tids to be set. for (std::vector<thread_t>::iterator it = runners.begin(); it != runners.end(); ++it) { ASSERT_TRUE(WaitForNonZero(&it->state, 10)); } // Start all of the dumpers at once, they will spin until they are signalled // to begin their dump run. int32_t dump_now = 0; for (size_t i = 0; i < NUM_THREADS; i++) { dumpers[i].thread.tid = runners[i].tid; dumpers[i].thread.state = 0; dumpers[i].done = 0; dumpers[i].now = &dump_now; ASSERT_TRUE(pthread_create(&dumpers[i].thread.threadId, &attr, ThreadDump, &dumpers[i]) == 0); } // Start all of the dumpers going at once. android_atomic_acquire_store(1, &dump_now); for (size_t i = 0; i < NUM_THREADS; i++) { ASSERT_TRUE(WaitForNonZero(&dumpers[i].done, 10)); // Tell the runner thread to exit its infinite loop. android_atomic_acquire_store(0, &runners[i].state); ASSERT_TRUE(dumpers[i].backtrace != NULL); VerifyMaxDump(dumpers[i].backtrace); delete dumpers[i].backtrace; dumpers[i].backtrace = NULL; } }