int main() { Counter c; printf("c=%d\n", c.get()); c.inc(); printf("c=%d\n", c.get()); c.inc(2); printf("c=%d\n", c.get()); c.dec(); printf("c=%d\n", c.get()); c.dec(2); printf("c=%d\n", c.get()); c.reset(5); printf("c=%d\n", c.get()); return 0; }
/** Update counters that are lazily-computed. */ virtual void finalizeCounters() { numTotalMemoryAccesses = numReadHits.get() + numReadRemoteHits.get() + numReadMisses.get() + numWriteHits.get() + numWriteRemoteHits.get() + numWriteMisses.get() + numUpgradeMisses.get(); }
static int receiveConstRef(const Counter& counter) { BOOST_CHECK_EQUAL(counter.get(), 24); return counter.get(); }
static int receiveRef(Counter& counter) { BOOST_CHECK_EQUAL(counter.get(), 42); counter.set(24); return counter.get(); }
static int receiveConstValue(const Counter counter) { BOOST_CHECK_EQUAL(counter.get(), 42); return counter.get(); }