Ejemplo n.º 1
0
//
// 如何处理各种Command呢?
// 一般用于不同对象之间的通信,包括cross thread的通信
// 各种相关的函数实现已经定义好
//
void zmq::object_t::process_command(command_t &cmd_) {
    switch (cmd_.type) {

        case command_t::activate_read:
            process_activate_read();
            break;

        case command_t::activate_write:
            process_activate_write(cmd_.args.activate_write.msgs_read);
            break;

        case command_t::stop:
            process_stop();
            break;

        case command_t::plug:
            process_plug();
            process_seqnum();
            break;

        case command_t::own:
            process_own(cmd_.args.own.object);
            process_seqnum();
            break;

        case command_t::attach:
            process_attach(cmd_.args.attach.engine);
            process_seqnum();
            break;

        case command_t::bind:
            process_bind(cmd_.args.bind.pipe);
            process_seqnum();
            break;

        case command_t::hiccup:
            process_hiccup(cmd_.args.hiccup.pipe);
            break;

        case command_t::pipe_term:
            process_pipe_term();
            break;

        case command_t::pipe_term_ack:
            process_pipe_term_ack();
            break;

        case command_t::term_req:
            process_term_req(cmd_.args.term_req.object);
            break;

        case command_t::term:
            process_term(cmd_.args.term.linger);
            break;

        case command_t::term_ack:
            process_term_ack();
            break;

        case command_t::reap:
            process_reap(cmd_.args.reap.socket);
            break;

        case command_t::reaped:
            process_reaped();
            break;

        case command_t::inproc_connected:
            process_seqnum();
            break;

        case command_t::done:
        default:
            zmq_assert (false);
    }
}
Ejemplo n.º 2
0
void zmq::object_t::process_command (command_t &cmd_)
{
    switch (cmd_.type) {

    case command_t::activate_read:
        process_activate_read ();
        break;

    case command_t::activate_write:
        process_activate_write (cmd_.args.activate_write.msgs_read);
        break;

    case command_t::stop:
        process_stop ();
        break;

    case command_t::plug:
        process_plug ();
        process_seqnum ();
        break;

    case command_t::own:
        process_own (cmd_.args.own.object);
        process_seqnum ();
        break;

    case command_t::attach:
        process_attach (cmd_.args.attach.engine,
            cmd_.args.attach.peer_identity ?
            blob_t (cmd_.args.attach.peer_identity,
            cmd_.args.attach.peer_identity_size) : blob_t ());
        process_seqnum ();
        break;

    case command_t::bind:
        process_bind (cmd_.args.bind.pipe, cmd_.args.bind.peer_identity ?
            blob_t (cmd_.args.bind.peer_identity,
            cmd_.args.bind.peer_identity_size) : blob_t ());
        process_seqnum ();
        break;

    case command_t::hiccup:
        process_hiccup (cmd_.args.hiccup.pipe);
        break;

    case command_t::pipe_term:
        process_pipe_term ();
        break;

    case command_t::pipe_term_ack:
        process_pipe_term_ack ();
        break;

    case command_t::term_req:
        process_term_req (cmd_.args.term_req.object);
        break;
    
    case command_t::term:
        process_term (cmd_.args.term.linger);
        break;

    case command_t::term_ack:
        process_term_ack ();
        break;

    case command_t::reap:
        process_reap (cmd_.args.reap.socket);
        break;

    case command_t::reaped:
        process_reaped ();
        break;

    default:
        zmq_assert (false);
    }

    //  The assumption here is that each command is processed once only,
    //  so deallocating it after processing is all right.
    deallocate_command (&cmd_);
}