• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ static_hashed_set类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中static_hashed_set的典型用法代码示例。如果您正苦于以下问题:C++ static_hashed_set类的具体用法?C++ static_hashed_set怎么用?C++ static_hashed_set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了static_hashed_set类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: run

    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);
    }
开发者ID:pkarasev3,项目名称:ecto,代码行数:35,代码来源:stack_test.cpp


示例2: run

    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);
    }
开发者ID:chenbk85,项目名称:boost_lockfree,代码行数:26,代码来源:fifo_test.cpp


示例3: get_items

    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;
        }
    }
开发者ID:jmargeta,项目名称:boost-svn,代码行数:17,代码来源:test_common.hpp


示例4: deallocate

    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);
        }
    }
开发者ID:mokerjoke,项目名称:boost-svn,代码行数:21,代码来源:freelist_test.cpp


示例5: add_items

    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;
        }
    }
开发者ID:pkarasev3,项目名称:ecto,代码行数:14,代码来源:stack_test.cpp


示例6: allocate

 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;
             }
         }
     }
 }
开发者ID:mokerjoke,项目名称:boost-svn,代码行数:14,代码来源:freelist_test.cpp


示例7: add_items

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);
    }
}
开发者ID:jellevandenhooff,项目名称:codex,代码行数:16,代码来源:stack_test.cpp


示例8: add_items

    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;
        }
    }
开发者ID:jmargeta,项目名称:boost-svn,代码行数:17,代码来源:test_common.hpp


示例9: get_items

    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;
        }
    }
开发者ID:mrotondo,项目名称:poopworm,代码行数:17,代码来源:stack_test.cpp


示例10: get_items

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;
    }
}
开发者ID:jellevandenhooff,项目名称:codex,代码行数:18,代码来源:stack_test.cpp


示例11: add

    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;
        }
    }
开发者ID:chenbk85,项目名称:boost_lockfree,代码行数:19,代码来源:fifo_test.cpp


示例12: add

    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;
        }
    }
开发者ID:Tbxhs,项目名称:boost-svn,代码行数:20,代码来源:spsc_queue_test.cpp



注:本文中的static_hashed_set类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ statik类代码示例发布时间:2022-05-31
下一篇:
C++ statet类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap