bool
Coordinator::event(QEvent* event)
{
    if(event->type() != CUSTOM_EVENT_TYPE)
    {
        return QObject::event(event);
    }

    CustomEvent* customEvent = dynamic_cast<CustomEvent*>(event);
    assert(customEvent);
    Ice::DispatcherCallPtr call = customEvent->call();
    assert(call);
    try
    {
        call->run();
    }
    catch(const Ice::Exception& ex)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (Ice::Exception):\n" << ex;
        setError(error.str());
    }
    catch(const exception& ex)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (std::exception):\n" << ex.what();
        setError(error.str());
    }
    catch(const string& ex)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (std::string):\n" << ex;
        setError(error.str());
    }
    catch(const char* ex)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (const char*):\n" << ex;
        setError(error.str());
    }
    catch(...)
    {
        ostringstream error;
        error << "Ice::DispatcherCall (unknown C++ exception).";
        setError(error.str());
    }
    return true;
}
Exemple #2
0
void
SessionHelperI::dispatchCallback(const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr& conn)
{
    if(_initData.dispatcher)
    {
#ifdef ICE_CPP11_MAPPING
        _initData.dispatcher([call]()
            {
                call->run();
            },
            conn);
#else
        _initData.dispatcher->dispatch(call, conn);
#endif
    }
    else
    {
        call->run();
    }
}
Exemple #3
0
void
Dispatcher::run()
{
    while(true)
    {
        Ice::DispatcherCallPtr call;
        {
            Lock sync(*this);
            
            while(!_terminated && _calls.empty())
            {               
                wait();
            }
            
            if(!_calls.empty())
            {
                call = _calls.front();
                _calls.pop_front();
            }
            else if(_terminated)
            {
                // Terminate only once all calls are dispatched.
                return;
            }
        }
        
        
        if(call)
        {
            try
            {
                call->run();
            }
            catch(...)
            {
                // Exceptions should never propagate here.
                test(false);
            }
        }
    }
}
Exemple #4
0
void
SessionHelperI::dispatchCallback(const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr& conn)
{
    if(_initData.dispatcher)
    {
        _initData.dispatcher->dispatch(call, conn);
    }
    else
    {
        call->run();
    }
}
Exemple #5
0
void
SessionHelperI::dispatchCallbackAndWait(const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr& conn)
{
    if(_initData.dispatcher)
    {
        IceUtilInternal::CountDownLatch cdl(1);
        Ice::DispatcherCallPtr callWait = new DispatcherCallWait(cdl, call);
#ifdef ICE_CPP11_MAPPING
        _initData.dispatcher([call]()
            {
                call->run();
            },
            conn);
#else
        _initData.dispatcher->dispatch(callWait, conn);
#endif
        cdl.await();
    }
    else
    {
        call->run();
    }
}
void
SessionHelperI::dispatchCallbackAndWait(const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr& conn)
{
    if(_initData.dispatcher)
    {
        IceUtilInternal::CountDownLatch cdl(1);
        Ice::DispatcherCallPtr callWait = new DispatcherCallWait(cdl, call);
        _initData.dispatcher->dispatch(callWait, conn);
        cdl.await();
    }
    else
    {
        call->run();
    }
}