当前位置: 首页>>代码示例>>C++>>正文


C++ concurrent_queue::pop方法代码示例

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


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

示例1: main

int main()
{
    srand(time(0));

    // Custom scheduling is not required - can be integrated
    // to other systems transparently
    main_tasks.push([]
    {
        asynchronous([]
        {
            return async_user_handler(),
                   finished = true;
        });
    });

    Task task;
    while(!finished)
    {
        main_tasks.pop(task);
        task();
    }

    cout << "Done" << std::endl;

    return EXIT_SUCCESS;
}
开发者ID:ElaraFX,项目名称:boost,代码行数:26,代码来源:await_emu.cpp

示例2: ccr_worker

static void* ccr_worker(void *arg)
{
    int r, resume;
    process_t *proc;
    while (1)
    {
        // Checks if threads need to be killed and the the ready procces's queue is empty
        // That way only when the queue is empty the threads are killed
        // if ((free_flag.compare_and_swap(false, true)) && (prc_ready.empty()))
        if (free_flag.compare_and_swap(false, true))
        {
            pthread_t thread = pthread_self();
            // removes reference from the pool
            thr_pool.remove(thread);

            // checks if threre's more threads to kill and set the flag
            if (free_workers.fetch_and_decrement() > 1)
            {
                free_flag.compare_and_swap(true, false);
            }

            //kills the current thread
            pthread_exit(NULL);
        }
        prc_ready.pop(proc);
        if (!proc) return NULL;
        r = lua_resume(proc->L, 0);
        switch (r)
        {
            case  LUA_YIELD:
                //cerr << "Yield!\n";
                switch (proc->status)
                {
                    case PS_READY:
                        // releasing the lock acquired in ccr_yield
                        proc->wlock.release();
                        prc_ready.push(proc);
                        break;
                    case PS_BLOCKING:
                        proc->status = PS_BLOCKED;
                        // releasing the lock acquired in ccr_yield
                        proc->wlock.release();
                        break;
                }
                break;
            case LUA_ERRRUN:
            case LUA_ERRMEM:
            case LUA_ERRERR:
                cerr << "[ERROR][PROCESSING A LUA PROCESS] " << lua_tostring(proc->L, -1) << endl;
                // fall-through
            case 0:
                lua_close(proc->L);
                mbx_close(proc->mbox);
                prc_free(proc);
                break;
        }
    }
    return NULL;
}
开发者ID:DaiYamatta,项目名称:ALua,代码行数:59,代码来源:ccr.cpp

示例3: concurrent

 concurrent( T t_ ) : t{t_}, thd{[=]{ while(!done) q.pop()(); }} { }
开发者ID:CCJY,项目名称:coliru,代码行数:1,代码来源:main.cpp


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