Exemplo n.º 1
0
void zmq::object_t::process_command (command_t &cmd_)
{
    switch (cmd_.type) {

    case command_t::revive:
        process_revive ();
        break;

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

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

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

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

    case command_t::bind:
        process_bind (cmd_.args.bind.in_pipe, cmd_.args.bind.out_pipe);
        process_seqnum ();
        return;

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

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

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

    case command_t::term:
        process_term ();
        return;

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

    default:
        zmq_assert (false);
    }
}
Exemplo n.º 2
0
void ymq::YObject::process_command(ymq::YCommand &cmd) {

    switch (cmd.type){

        case ymq::YCommand::plug :

            process_plug();
            break;

        case ymq::YCommand::bind :

            process_bind();
            break;
    }
}
Exemplo n.º 3
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);
    }
}
Exemplo n.º 4
0
void zmq::object_t::process_command (command_t &cmd_)
{
    switch (cmd_.type) {

    case command_t::revive:
        process_revive ();
        break;

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

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

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

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

    case command_t::bind:
        process_bind (cmd_.args.bind.in_pipe, cmd_.args.bind.out_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::reader_info:
        process_reader_info (cmd_.args.reader_info.msgs_read);
        break;

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

    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 ();
        break;

    case command_t::term_ack:
        process_term_ack ();
        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_);
}
Exemplo n.º 5
0
int main(int argc, char **argv) {
	GetOpt opt(argc,argv,"8vfcSLBDs:l:b:d:o:r:");
	int c, rc;
	argv0 = argv[0];
	while ((c = opt()) != EOF) {
		switch (c) {
			case '8': // 8 byte serial #; for janet only.
				long_oids = 1;
			break;
			case 'v': // verbose
				verbose_flag = 1;
			break;
			case 'f' : //  overwrite existing module if found.
				overwrite_module = 1;
			break;
			case 'c' : //  syntax check only
				scheck_only = 1;
			break;
			case 'S': // read from standard input
				src_args[src_count++] = "-";
			break;
			case 'B': // print out language binding for all modules processed.
				bind_all = 1;
			break;
			case 'L': // link all modules processed  (from source).
				link_all = 1;
			break;
			case 'D':
				debug++;
			break;
			case 's':
				src_args[src_count++] = opt.optarg;
			break;
			case 'r':
				rm_args[rm_count++] = opt.optarg;
			break;
			case 'l':
				link_args[link_count++] = opt.optarg;
			break;
			case 'b':
				bind_args[bind_count++] = opt.optarg;
			break;
			case 'd':
				dir_args[dir_count++] = opt.optarg;
			break;
			case 'o':
				if (output_arg)	
				{
					cerr << "only one output file name allowed" <<endl;
					usage(argv[0]);
				}
				output_arg = opt.optarg;
			break;
			default:
				usage(argv[0]);
				return 1;
		}
	}
	int i;
	if (debug || verbose_flag) {
		fprintf(stderr,"sdl: command line was\n\t");
		for (i = 0; i < argc; i++)
			fprintf(stderr,"%s ",argv[i]);
		fprintf(stderr,"\n");

		if (src_count>0)
		{
			fprintf(stderr,"compiling sdl source files: ");
			for (i = 0; i<src_count; i++)
				fprintf(stderr,"%s ",src_args[i]);
			fprintf(stderr,"\n");
		}
		if (link_count>0)
		{
			fprintf(stderr,"linking moudles: ");
			for (i = 0; i<link_count; i++)
				fprintf(stderr,"%s ",link_args[i]);
			fprintf(stderr,"\n");
		}
		if (bind_count>0)
		{
			fprintf(stderr,"creating language binding for modules: ");
			for (i = 0; i<bind_count; i++)
				fprintf(stderr,"%s ",bind_args[i]);
			fprintf(stderr,"\n");
		}
		if (dir_count>0)
		{
			fprintf(stderr,"shore directory search path: ");
			for (i = 0; i<dir_count; i++)
				fprintf(stderr,"%s ",dir_args[i]);
			fprintf(stderr,"\n");
		}
		if ( bind_all)
			fprintf(stderr,"-B: printing language binding for all source processed\n");
		if ( link_all)
			fprintf(stderr,"-L: linking modules for all source processed\n");
		if ( overwrite_module)
			fprintf(stderr,"-f: deleting existing modules\n");
		if (scheck_only)
			fprintf(stderr,"-c: syntax check only\n");


	}
	// initialization:
	if (!scheck_only)
		metaobj_init(argc,argv);
	if (src_count)
		insert_rwords();
	if (dir_count)
	{
		w_rc_t crc;
		for (i=0; i<dir_count; i++)
			add_dir(dir_args[i]);
		// also, chdir to 1st dir arg, creating it if necessary.
		W_COERCE(Shore::begin_transaction(3));
		crc = Shore::chdir(dir_args[0]);
		if (crc)
		{
			if (crc.err_num() != SH_NotFound)
				crc.fatal(); //give up
			SH_DO(Shore::mkdir(dir_args[0],0755));
			SH_DO(Shore::chdir(dir_args[0]));
		}
		SH_DO(SH_COMMIT_TRANSACTION);
	}
	// first, remove anything specified by -r
	if (rm_count >0)
		rm_files(rm_count,rm_args);
		
	for (i = 0; i<src_count; i++) {
		if ((rc = process_src( src_args[i])))
			return rc;
		if (sdl_errors)
		{
			fprintf(stderr,"found %d errors processing sdl source file %s\n",
				sdl_errors,src_args[i]);
			return sdl_errors;
		}
	}
	if (src_count && (g_module_list!= 0)) // say what we created
	{
		char * m_dir = dir_count? dir_args[0]: "/types";
		W_COERCE(Shore::begin_transaction(3));
		Ref<sdlDeclaration> lpt;

		for (lpt = g_module_list; lpt != NULL; lpt = lpt->next)
			fprintf(stderr,"created module 	%s/%s\n",m_dir,(char *)lpt->name);
		SH_DO(SH_COMMIT_TRANSACTION);
	}
	if ( scheck_only && (link_count || bind_all || bind_count))
	{
		fprintf(stderr,"cannot link or bind with -c flag\n");
		return sdl_errors;
	}
	if (link_all)
		if (rc = link_all_modules())
			return rc;
	for (i = 0; i < link_count; i++) {
		if ((rc = process_link( link_args[i])))
			return rc;
	}
	if (bind_all) //orint all bindings from src module list
		if (rc = print_all_bindings())
			return rc;
	if (bind_count == 1) // old style binding printout
	{
		if ((rc = process_bind(bind_args[i])))
			return rc;
	}
	else if (bind_count > 0)
	{
		Set<Ref<sdlModule> > omods;
		W_COERCE(Shore::begin_transaction(3));
		
		for (i = 0; i < bind_count; i++) 
		{
			Ref<sdlModule> bmod;
			bmod = lookup_module(bind_args[i]);
			if (bmod == 0) // null value
			{
				cerr << "couldn't find module " <<  bind_args[i] << endl;
				break;
			}
			omods.add(bmod);
		}
		if (omods.get_size()>0 
			&& open_output_file(omods.get_elt(0)->name.string()) == 0)
				print_cxx_binding(omods);
		W_COERCE(SH_COMMIT_TRANSACTION);
	}
	return sdl_errors;
}
Exemplo n.º 6
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_);
}