Пример #1
0
void enqueue(LockFreeQueue<DummyEntry> &the_queue, std::list<DummyEntry*> &enqueued,
             uint32_t key) {
    DummyEntry* entry = new DummyEntry(key);
    SCOPED_TRACE(testing::Message() << "new pointer=0x" << std::hex <<
        reinterpret_cast<uintptr_t>(entry) << std::dec << ", key=" << key);
    enqueued.push_back(entry);
    EXPECT_FALSE(contains(key, the_queue));

    the_queue.enqueue(entry);

    the_queue.unsafe_dump(std::cout);
    EXPECT_TRUE(contains(key, the_queue));
    EXPECT_TRUE(the_queue.unsafe_consistent());
    check_size(enqueued.size(), the_queue);

    the_queue.unsafe_dump(std::cout);
}
Пример #2
0
void dequeue(LockFreeQueue<DummyEntry> &the_queue, std::list<DummyEntry*> &enqueued) {
    DummyEntry* expected = enqueued.front(); enqueued.pop_front();
    SCOPED_TRACE(testing::Message() << "expected=0x" << std::hex <<
        reinterpret_cast<uintptr_t>(expected) << std::dec << ", key=" << expected->_key);
    EXPECT_TRUE(contains(expected->_key, the_queue));

    DummyEntry* ret = the_queue.dequeue();
    EXPECT_EQ(expected->_key, ret->_key);
    EXPECT_EQ(expected, ret);

    EXPECT_FALSE(contains(expected->_key, the_queue));
    EXPECT_TRUE(the_queue.unsafe_consistent());
    check_size(enqueued.size(), the_queue);

    the_queue.unsafe_dump(std::cout);
    delete ret;
}