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


C++ ACE_Thread_Manager::resume_all方法代码示例

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


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

示例1: defined

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
    if (parse_args (argc, argv) == -1)
        return -1;

    if (remote)
    {
        ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host));
        global_rlock = (ACE_Token_Proxy *) new
                       ACE_Remote_RLock ("THE_TOKEN", ignore_deadlock, debug);
        global_wlock = (ACE_Token_Proxy *) new
                       ACE_Remote_WLock ("THE_TOKEN", ignore_deadlock, debug);
    }
    else
    {
        global_rlock = (ACE_Token_Proxy *) new
                       ACE_Local_RLock ("THE_TOKEN", ignore_deadlock, debug);
        global_wlock = (ACE_Token_Proxy *) new
                       ACE_Local_WLock ("THE_TOKEN", ignore_deadlock, debug);
    }

    ACE_Thread_Manager mgr;

    if (mgr.spawn_n (threads, ACE_THR_FUNC (run_thread),
                     (void *) 0,
                     THR_BOUND | SUSPEND) == -1)
        ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1);

#if ! defined (ACE_HAS_PTHREADS)
    if (mgr.resume_all () == -1)
        ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1);
#endif

    mgr.wait ();

    return 0;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:38,代码来源:rw_locks.cpp

示例2: collectionAR

int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
    if (parse_args (argc, argv) == -1)
        return -1;

    ACE_Token_Proxy *A;  // Mutex *A*.
    ACE_Token_Proxy *B;  // Mutex *B*.
    ACE_Token_Proxy *R;  // *R*eader Lock.
    ACE_Token_Proxy *W;  // *W*riter Lock.

    // Depending on the command line arguments, we will create local or
    // remote tokens.  The names of the tokens are not important as long
    // as they are unique.
    if (remote)
    {
        ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host));
        A = new ACE_Remote_Mutex ("R Mutex A", 0, debug);
        B = new ACE_Remote_Mutex ("R Mutex B", 0, debug);
        R = new ACE_Remote_RLock ("R Reader Lock", 0, debug);
        W = new ACE_Remote_WLock ("R Writer Lock", 0, debug);
    }
    else
    {
        A = new ACE_Local_Mutex ("L Mutex A", 0, debug);
        B = new ACE_Local_Mutex ("L Mutex B", 0, debug);
        R = new ACE_Local_RLock ("L Reader Lock", 0, debug);
        W = new ACE_Local_WLock ("L Writer Lock", 0, debug);
    }

    // These collections will be treated as Tokens by the threads.
    ACE_Token_Collection collectionAR (debug, "A and Reader");
    ACE_Token_Collection collectionAW (debug, "A and Writer");
    ACE_Token_Collection collectionBR (debug, "B and Reader");

    // AR and BR can run concurrently.  Neither AR or BR can run when AW
    // is running.
    collectionAR.insert (*A);
    collectionAR.insert (*R);

    collectionAW.insert (*A);
    collectionAW.insert (*W);

    collectionBR.insert (*B);
    collectionBR.insert (*R);

    // Spawn off three threads.
    ACE_Thread_Manager *mgr = ACE_Thread_Manager::instance ();

    if (mgr->spawn (ACE_THR_FUNC (run_thread),
                    (void *) &collectionAR, THR_BOUND | THR_SUSPENDED) == -1)
        ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 1 failed"), -1);

    if (mgr->spawn (ACE_THR_FUNC (run_thread),
                    (void *) &collectionAW, THR_BOUND | THR_SUSPENDED) == -1)
        ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 2 failed"), -1);

    if (mgr->spawn (ACE_THR_FUNC (run_thread),
                    (void *) &collectionBR, THR_BOUND | THR_SUSPENDED) == -1)
        ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 3 failed"), -1);

#if ! defined (ACE_HAS_PTHREADS)
    if (mgr->resume_all () == -1)
        ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1);
#endif

    // Wait for all threads to exit.
    mgr->wait ();

    return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:71,代码来源:collection.cpp


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