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


C++ ThreadPtr::getThreadControl方法代码示例

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


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

示例1: sync

void
Glacier2::SessionFactoryHelper::addThread(const SessionHelper* session, const IceUtil::ThreadPtr& thread)
{
    //
    // A SessionHelper can only ever have one thread running. Therefore any
    // currently registered thread for the same session must be finished, so
    // we just replace it.
    //
    IceUtil::ThreadPtr previous;
    {
        IceUtil::Mutex::Lock sync(_mutex);
        map<const SessionHelper*, IceUtil::ThreadPtr>::iterator p = _threads.find(session);
        if(p != _threads.end())
        {
            previous = p->second;
            p->second = thread;
        }
        else
        {
            _threads.insert(make_pair(session, thread));
        }
    }
    if(previous)
    {
        //
        // Join previous thread, joining outside the synchronization is important to prevent deadlocks.
        //
        previous->getThreadControl().join();
    }
}
开发者ID:SmarkSeven,项目名称:ice,代码行数:30,代码来源:SessionHelper.cpp

示例2: startHook

static unsigned int
WINAPI startHook(void* arg)
{
    // Ensure that the thread doesn't go away until run() has
    // completed.
    //
    IceUtil::ThreadPtr thread;

    try
    {
        IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);

        //
        // Ensure that the thread doesn't go away until run() has
        // completed.
        //
        thread = rawThread;

        //
        // Initialize the random number generator in each thread on
        // Windows (the rand() seed is thread specific).
        //
        unsigned int seed = static_cast<unsigned int>(IceUtil::Time::now().toMicroSeconds());
        srand(seed ^ static_cast<unsigned int>(hash<thread::id>()(thread->getThreadControl().id())));

        //
        // See the comment in IceUtil::Thread::start() for details.
        //
        rawThread->__decRef();
        pthread_setname_np(thread->name().c_str());
        thread->run();
    }
    catch(...)
    {
        if(!thread->name().empty())
        {
            cerr << thread->name() << " terminating" << endl;
        }
        std::terminate();
    }

    thread->_done();
   
    return 0;
}
开发者ID:lgdiy1982,项目名称:SDLAudioPlayer,代码行数:45,代码来源:Thread.cpp

示例3: lock

void
CallbackSenderI::destroy()
{
    IceUtil::ThreadPtr callbackSenderThread;

    {
        Lock lock(*this);
        
        printf("destroying callback sender\n");
        _destroy = true;
        
        notify();

        callbackSenderThread = _callbackSenderThread;
        _callbackSenderThread = 0; // Resolve cyclic dependency.
    }

    callbackSenderThread->getThreadControl().join();
}
开发者ID:glockwork,项目名称:dfu,代码行数:19,代码来源:CallbackI.cpp

示例4: lock

void
CallbackSenderI::destroy()
{
    IceUtil::ThreadPtr callbackSenderThread;

    {
        IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
        
        cout << "destroying callback sender" << endl;
        _destroy = true;
        
        notify();

        callbackSenderThread = _callbackSenderThread;
        _callbackSenderThread = 0; // Resolve cyclic dependency.
    }

    callbackSenderThread->getThreadControl().join();
}
开发者ID:bholl,项目名称:zeroc-ice,代码行数:19,代码来源:CallbackI.cpp

示例5: sync

void
ServiceStatusManager::stopUpdate()
{
    IceUtil::ThreadPtr thread;

    {
        Lock sync(*this);

        if(_thread)
        {
            _stopped = true;
            notify();
            thread = _thread;
            _thread = 0;
        }
    }

    if(thread)
    {
        thread->getThreadControl().join();
    }
}
开发者ID:ming-hai,项目名称:ice,代码行数:22,代码来源:Service.cpp

示例6: lock

void mtsManagerProxyClient::ManagerClientI::Stop()
{
    if (!IsActiveProxy()) return;

    ManagerProxyClient = 0;

    IceUtil::ThreadPtr callbackSenderThread;
    {
        IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);

        notify();

        callbackSenderThread = SenderThreadPtr;
        
        // Prevent sender thread from sending any further message
        SenderThreadPtr->StopSend();
        SenderThreadPtr = 0;
    }
    callbackSenderThread->getThreadControl().join();
#ifdef ENABLE_DETAILED_MESSAGE_EXCHANGE_LOG
    LogPrint(ManagerClientI, "Stopped and destroyed callback thread to communicate with server");
#endif
}
开发者ID:Shuyoung,项目名称:cisst,代码行数:23,代码来源:mtsManagerProxyClient.cpp

示例7: ds


//.........这里部分代码省略.........
                Ice::CommunicatorPtr ic = Ice::initialize(initData);

                Ice::Context ctx;
                ctx["one"] = "ONE";
                ctx["two"] = "TWO";
                ctx["three"] = "THREE";

                Test::MyClassPrxPtr p = ICE_UNCHECKED_CAST(Test::MyClassPrx,
                                                           ic->stringToProxy("test:" + getTestEndpoint(ic, 0)));

                ic->getImplicitContext()->setContext(ctx);
                test(ic->getImplicitContext()->getContext() == ctx);
                test(p->opContext() == ctx);

                test(ic->getImplicitContext()->containsKey("zero") == false);
                string r = ic->getImplicitContext()->put("zero", "ZERO");
                test(r == "");
                test(ic->getImplicitContext()->containsKey("zero") == true);
                test(ic->getImplicitContext()->get("zero") == "ZERO");

                ctx = ic->getImplicitContext()->getContext();
                test(p->opContext() == ctx);
                Ice::Context prxContext;
                prxContext["one"] = "UN";
                prxContext["four"] = "QUATRE";

                Ice::Context combined = prxContext;
                combined.insert(ctx.begin(), ctx.end());
                test(combined["one"] == "UN");

                p = ICE_UNCHECKED_CAST(Test::MyClassPrx, p->ice_context(prxContext));

                ic->getImplicitContext()->setContext(Ice::Context());
                test(p->opContext() == prxContext);

                ic->getImplicitContext()->setContext(ctx);
                test(p->opContext() == combined);

                test(ic->getImplicitContext()->remove("one") == "ONE");

                if(impls[i] == "PerThread")
                {
                    IceUtil::ThreadPtr thread = new PerThreadContextInvokeThread(p->ice_context(Ice::Context()));
                    thread->start();
                    thread->getThreadControl().join();
                }

                ic->getImplicitContext()->setContext(Ice::Context()); // Clear the context to avoid leak report.
                ic->destroy();
            }
        }
#endif
        }

    {
        Ice::Double d = 1278312346.0 / 13.0;
        Test::DoubleS ds(5, d);
        p->opDoubleMarshaling(d, ds);
    }

    p->opIdempotent();

    p->opNonmutating();

    test(p->opByte1(0xFF) == 0xFF);
    test(p->opShort1(0x7FFF) == 0x7FFF);
    test(p->opInt1(0x7FFFFFFF) == 0x7FFFFFFF);
    test(p->opLong1(0x7FFFFFFFFFFFFFFFLL) == 0x7FFFFFFFFFFFFFFFLL);
    test(p->opFloat1(1.0) == 1.0);
    test(p->opDouble1(1.0) == 1.0);
    test(p->opString1("opString1") == "opString1");

    Test::MyDerivedClassPrxPtr d = ICE_UNCHECKED_CAST(Test::MyDerivedClassPrx, p);

    Test::MyStruct1 s;
    s.tesT = "Test::MyStruct1::s";
    s.myClass = 0;
    s.myStruct1 = "Test::MyStruct1::myStruct1";
    s = d->opMyStruct1(s);
    test(s.tesT == "Test::MyStruct1::s");
    test(s.myClass == 0);
    test(s.myStruct1 == "Test::MyStruct1::myStruct1");

    Test::MyClass1Ptr c = ICE_MAKE_SHARED(Test::MyClass1);
    c->tesT = "Test::MyClass1::testT";
    c->myClass = 0;
    c->myClass1 = "Test::MyClass1::myClass1";
    c = d->opMyClass1(c);
    test(c->tesT == "Test::MyClass1::testT");
    test(c->myClass == 0);
    test(c->myClass1 == "Test::MyClass1::myClass1");

    Test::StringS seq;
    p->opStringS1(seq);

    Test::ByteBoolD dict;
    p->opByteBoolD1(dict);


}
开发者ID:chenbk85,项目名称:ice,代码行数:101,代码来源:Twoways.cpp


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