Example #1
0
void
TimeoutI::holdAdapter(Ice::Int to, const Ice::Current& current)
{
    current.adapter->hold();
    IceUtil::ThreadPtr thread = new ActivateAdapterThread(current.adapter, to);
    IceUtil::ThreadControl threadControl = thread->start();
    threadControl.detach();
}
Example #2
0
void 
Test::AccountI::transfer3_async(const AMD_Account_transfer3Ptr& cb, int amount, const Test::AccountPrx& toAccount, const Current& current)
{
    //
    // Here the dispatch thread does the actual work, but a separate thread sends the response
    //

    ResponseThreadPtr thread = new ResponseThread(cb);
    IceUtil::ThreadControl tc = thread->start(33000);
    
    test(_evictor->getCurrentTransaction() != 0);

    try
    {
        toAccount->deposit(amount); // collocated call
        deposit(-amount, current); // direct call
    }
    catch(const Ice::UserException& e)
    {
        tc.detach();

        //
        // Need to rollback here -- "rollback on user exception" does not work
        // when the dispatch commits before it gets any response!
        //
        _evictor->getCurrentTransaction()->rollback();
        
        thread->exception(e);

        return;
    }
    catch(...)
    {
        thread->cancel();
        tc.join();
        throw;
    }

    tc.detach();
    thread->response();
}