Example #1
0
    void run(void)
    {
        BOOST_WARN(stk.is_lock_free());

        running.store(true);

        thread_group writer;
        thread_group reader;

        BOOST_REQUIRE(stk.empty());

        for (int i = 0; i != reader_threads; ++i)
            reader.create_thread(boost::bind(&stack_tester::get_items, this));

        for (int i = 0; i != writer_threads; ++i)
            writer.create_thread(boost::bind(&stack_tester::add_items, this));

        using namespace std;
        cout << "threads created" << endl;

        writer.join_all();

        cout << "writer threads joined, waiting for readers" << endl;

        running = false;
        reader.join_all();

        cout << "reader threads joined" << endl;

        BOOST_REQUIRE_EQUAL(data.count_nodes(), 0);
        BOOST_REQUIRE(stk.empty());

        BOOST_REQUIRE_EQUAL(push_count, pop_count);
        BOOST_REQUIRE_EQUAL(push_count, writer_threads * node_count);
    }
Example #2
0
    void run(void)
    {
        running = true;

        thread_group writer;
        thread_group reader;

        BOOST_REQUIRE(sf.empty());
        for (int i = 0; i != reader_threads; ++i)
            reader.create_thread(boost::bind(&fifo_tester::get, this));

        for (int i = 0; i != writer_threads; ++i)
            writer.create_thread(boost::bind(&fifo_tester::add, this));
        cout << "reader and writer threads created" << endl;

        writer.join_all();
        cout << "writer threads joined. waiting for readers to finish" << endl;

        running = false;
        reader.join_all();

        BOOST_REQUIRE_EQUAL(received_nodes, writer_threads * nodes_per_thread);
        BOOST_REQUIRE_EQUAL(fifo_cnt, 0);
        BOOST_REQUIRE(sf.empty());
        BOOST_REQUIRE(working_set.count_nodes() == 0);
    }
Example #3
0
    void run(void)
    {
        running = true;

        thread reader(boost::bind(&spsc_queue_tester_buffering::get, this));
        thread writer(boost::bind(&spsc_queue_tester_buffering::add, this));
        cout << "reader and writer threads created" << endl;

        writer.join();
        cout << "writer threads joined. waiting for readers to finish" << endl;

        reader.join();

        BOOST_REQUIRE_EQUAL(received_nodes, nodes_per_thread);
        BOOST_REQUIRE_EQUAL(spsc_queue_cnt, 0);
        BOOST_REQUIRE(sf.empty());
        BOOST_REQUIRE(working_set.count_nodes() == 0);
    }