Ejemplo n.º 1
0
    void add(void)
    {
        for (boost::uint32_t i = 0; i != nodes_per_thread; ++i) {
            int id = generate_id<int>();
            working_set.insert(id);

            while (sf.push(id) == false)
            {}

            ++spsc_queue_cnt;
        }
        running = false;
    }
Ejemplo n.º 2
0
    void add_items(void)
    {
        for (long i = 0; i != node_count; ++i)
        {
            long id = generate_id<long>();

            bool inserted = data.insert(id);
            assert(inserted);

            while(stk.push(id) == false)
                thread::yield();
            ++push_count;
        }
    }
Ejemplo n.º 3
0
 void allocate(void)
 {
     for (long i = 0; i != operations_per_thread; ++i)  {
         for (;;) {
             dummy * node = fl.template construct<true, bounded>();
             if (node) {
                 bool success = working_set.insert(node);
                 assert(success);
                 allocated_nodes.push(node);
                 break;
             }
         }
     }
 }
Ejemplo n.º 4
0
void add_items(void)
{
    unsigned long count = 1000000;

    for (long i = 0; i != count; ++i)
    {
        thread::yield();
        long id = generate_id<long>();

        bool inserted = data.insert(id);

        assert(inserted);

        stk.push(id);
    }
}
Ejemplo n.º 5
0
    void get_items(queue & stk)
    {
        for (;;) {
            long id;

            bool got = stk.pop(id);
            if (got) {
                bool erased = data.erase(id);
                bool inserted = dequeued.insert(id);
                assert(erased);
                assert(inserted);
                ++pop_count;
            } else
                if (!running.load())
                    return;
        }
    }
Ejemplo n.º 6
0
    void add_items(queue & stk)
    {
        for (long i = 0; i != node_count; ++i) {
            long id = generate_id<long>();

            bool inserted = data.insert(id);
            assert(inserted);

            if (Bounded)
                while(stk.bounded_push(id) == false)
                    /*thread::yield()*/;
            else
                while(stk.push(id) == false)
                    /*thread::yield()*/;
            ++push_count;
        }
    }
Ejemplo n.º 7
0
    void add(void)
    {
        for (unsigned i = 0; i != nodes_per_thread; ++i)
        {
            while(fifo_cnt > 10000)
                thread::yield();

            int id = generate_id<int>();

            working_set.insert(id);

            while (sf.enqueue(id) == false)
            {
                thread::yield();
            }

            ++fifo_cnt;
        }
    }
Ejemplo n.º 8
0
    void add(void)
    {
        boost::array<int, buf_size> input_buffer;
        for (boost::uint32_t i = 0; i != nodes_per_thread; i+=buf_size) {
            for (size_t i = 0; i != buf_size; ++i) {
                int id = generate_id<int>();
                working_set.insert(id);
                input_buffer[i] = id;
            }

            size_t pushed = 0;

            do {
                pushed += sf.push(input_buffer.c_array() + pushed,
                                  input_buffer.size()    - pushed);
            } while (pushed != buf_size);

            spsc_queue_cnt+=buf_size;
        }
    }