Ejemplo n.º 1
0
    void deallocate(void)
    {
        for (;;) {
            dummy * node;
            if (allocated_nodes.pop(node)) {
                bool success = working_set.erase(node);
                assert(success);
                fl.template destruct<true>(node);
            }

            if (running.load() == false)
                break;
        }

        dummy * node;
        while (allocated_nodes.pop(node)) {
            bool success = working_set.erase(node);
            assert(success);
            fl.template destruct<true>(node);
        }
    }
Ejemplo n.º 2
0
    bool get_element(void)
    {
        int data;
        bool success = sf.pop(data);

        if (success) {
            ++received_nodes;
            --spsc_queue_cnt;
            bool erased = working_set.erase(data);
            assert(erased);
            return true;
        } else
            return false;
    }
Ejemplo n.º 3
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.º 4
0
    void get_items(void)
    {
        for (;;)
        {
            long id;

            bool got = stk.pop(&id);
            if (got)
            {
                bool erased = data.erase(id);
                assert(erased);
                ++pop_count;
            }
            else if (not running)
                return;
        }
    }
Ejemplo n.º 5
0
void get_items(void)
{
    for (;;)
    {
        thread::yield();
        long id;

        bool got = stk.pop(&id);
        if (got)
        {
            bool erased = data.erase(id);
            assert(erased);
        }
        else
            if (not running)
                return;
    }
}
Ejemplo n.º 6
0
    bool get_elements(void)
    {
        boost::array<int, buf_size> output_buffer;

        size_t popd = sf.pop(output_buffer.c_array(), output_buffer.size());

        if (popd) {
            received_nodes += popd;
            spsc_queue_cnt -= popd;

            for (size_t i = 0; i != popd; ++i) {
                bool erased = working_set.erase(output_buffer[i]);
                assert(erased);
            }

            return true;
        } else
            return false;
    }