本文整理汇总了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();
}
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
}
示例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
}
示例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);
}