当前位置: 首页>>代码示例>>C++>>正文


C++ create_pipe函数代码示例

本文整理汇总了C++中create_pipe函数的典型用法代码示例。如果您正苦于以下问题:C++ create_pipe函数的具体用法?C++ create_pipe怎么用?C++ create_pipe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create_pipe函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: zmq_assert

void zmq::session_t::process_attach (i_engine *engine_,
    const blob_t &peer_identity_)
{
    //  If we are already terminating, we destroy the engine straight away.
    //  Note that we don't have to unplug it before deleting as it's not
    //  yet plugged to the session.
    if (state == terminating) {
        if (engine_)
            delete engine_;
        return;
    }

    //  If some other object (e.g. init) notifies us that the connection failed
    //  without creating an engine we need to start the reconnection process.
    if (!engine_) {
        zmq_assert (!engine);
        detached ();
        return;
    }

    //  Trigger the notfication event about the attachment.
    if (!attached (peer_identity_)) {
        delete engine_;
        return;
    }

    //  Check whether the required pipes already exist. If not so, we'll
    //  create them and bind them to the socket object.
    if (!pipes_attached) {
        zmq_assert (!in_pipe && !out_pipe);
        pipes_attached = true;
        reader_t *socket_reader = NULL;
        writer_t *socket_writer = NULL;

        //  Create the pipes, as required.
        if (options.requires_in) {
            create_pipe (socket, this, options.hwm, options.swap,
                &socket_reader, &out_pipe);
            out_pipe->set_event_sink (this);
        }
        if (options.requires_out) {
            create_pipe (this, socket, options.hwm, options.swap, &in_pipe,
                &socket_writer);
            in_pipe->set_event_sink (this);
        }

        //  Bind the pipes to the socket object.
        if (socket_reader || socket_writer)
            send_bind (socket, socket_reader, socket_writer, peer_identity_);
    }

    //  Plug in the engine.
    zmq_assert (!engine);
    engine = engine_;
    engine->plug (io_thread, this);
}
开发者ID:beamjs,项目名称:zeromq2,代码行数:56,代码来源:session.cpp

示例2: init_client_network

/**
 * Called by the main function of the game. Intializes the client network component of the game.
 * Requires 2 pipes as arguments, these will be passed for communication to network router. The
 * read descriptor of rcv_router_fd will be passed to the update system by the game, while the
 * write descriptor of the send_router_fd will be passed to the send_system.
 *
 * @param[in]   send_router_fd      Set of pipes created for passing data to the network router.
 * @param[in]   rcv_router_fd       Set of pipes created for grabbing data from the network router.
 *
 * @return      void
 *
 * @designer    Ramzi Chennafi
 * @author      Ramzi Chennafi
 */
void init_client_network(int send_router_fd[2], int rcv_router_fd[2], char * ip)
{
    pthread_t thread;
    PDATA pdata = (PDATA) malloc(sizeof(WTHREAD_DATA));

    create_pipe(send_router_fd);
    create_pipe(rcv_router_fd);

    pdata->read_pipe = send_router_fd[READ_END];
    pdata->write_pipe = rcv_router_fd[WRITE_END];
    memcpy(pdata->ip, ip, MAXIP);

    pthread_create(&thread, NULL, networkRouter, (void *)pdata);
    pthread_detach(thread);
}
开发者ID:kptnkrnch,项目名称:CutThePower_Backup,代码行数:29,代码来源:GameplayCommunication.cpp

示例3: zmq_assert

void zmq::session_t::process_attach (i_engine *engine_,
    const blob_t &peer_identity_)
{
    //  If some other object (e.g. init) notifies us that the connection failed
    //  we need to start the reconnection process.
    if (!engine_) {
        zmq_assert (!engine);
        detached ();
        return;
    }

    //  If we are already terminating, we destroy the engine straight away.
    if (finalised) {
        delete engine;
        return;
    }

    //  Check whether the required pipes already exist. If not so, we'll
    //  create them and bind them to the socket object.
    reader_t *socket_reader = NULL;
    writer_t *socket_writer = NULL;

    if (options.requires_in && !out_pipe) {
        create_pipe (socket, this, options.hwm, options.swap, &socket_reader,
            &out_pipe);
        out_pipe->set_event_sink (this);
    }

    if (options.requires_out && !in_pipe) {
        create_pipe (this, socket, options.hwm, options.swap, &in_pipe,
            &socket_writer);
        in_pipe->set_event_sink (this);
    }

    if (socket_reader || socket_writer)
        send_bind (socket, socket_reader, socket_writer, peer_identity_);

    //  Plug in the engine.
    zmq_assert (!engine);
    zmq_assert (engine_);
    engine = engine_;
    engine->plug (io_thread, this);

    attach_processed = true;

    //  Trigger the notfication about the attachment.
    attached (peer_identity_);
}
开发者ID:dell-esdk,项目名称:zeromq2,代码行数:48,代码来源:session.cpp

示例4: fb_hooks

void fb_hooks(const ALLEGRO_EVENT & event){
    switch(event.type){
        case ALLEGRO_EVENT_KEY_DOWN:
            keys[event.keyboard.keycode]=true;
            switch(event.keyboard.keycode){
                case ALLEGRO_KEY_SPACE:
                    if(!has_lost)
                        bird->im.rotation_vel=-(2.0f/3.0f)*(bird->im.rotation+PI/2);
                    break;
                case ALLEGRO_KEY_R:
                    clear_pipes();
                    break;
                case ALLEGRO_KEY_ESCAPE:
                    if(!show_menu){
                        show_menu=true;
                        menu->active=true;
                        start_button->active=true;
                        quit_button->active=true;
                        has_lost=true;
                    }else
                        quit_at_next_frame();
                    break;
            }
            break;
        case ALLEGRO_EVENT_KEY_UP:
            keys[event.keyboard.keycode]=false;
            break;
        case ALLEGRO_EVENT_TIMER:
            if(event.timer.source==fb_timer)
                create_pipe();
            break;
    }
}
开发者ID:ccapitalK,项目名称:si2e,代码行数:33,代码来源:floppy_bird.cpp

示例5: make_loop

void make_loop(int n, int* last_pipe, char* grammar) {
    /* last_pipe[0] = input of the recently created pipe    *
     * last_pipe[1] = output of the first pipe              */
	pid_t pid;
	if (n == 1) {
		prepare_input(last_pipe);
        prepare_output(last_pipe);
        close_pipe(last_pipe);
        return;
	}
	int next_pipe[2];
    create_pipe(next_pipe);
	switch (pid = fork()) {
		case -1:
			syserr("Error in fork()\n");
		case 0:
			prepare_input(last_pipe);
            close_pipe(last_pipe);
            prepare_output(next_pipe);
            close_pipe(next_pipe);
			execl("./worker", "./worker", grammar, NULL);
			syserr("Error in execl()\n");
		default:
            last_pipe[0] = next_pipe[0];
            make_loop(n - 1, last_pipe, grammar);
            return;
	}
}
开发者ID:ertesh,项目名称:SO,代码行数:28,代码来源:manager.c

示例6: execute_command_line

int execute_command_line(char *line, char *argv[]) {

    int  num_of_commands = 0;
    enum cmd_pos pos     = unknown;
    int  left_pipe[2]    = {-1, -1};
    int  right_pipe[2]   = {-1, -1};

    do {

        // Repeat this loop for each of the commands separated by '|' in
        // the command pipeline.

        // Use the next_command() parser to get the position and argument
        // vector of the next command in the command pipeline.
        pos = next_command(line, argv);

        create_pipe(pos, right_pipe);


        fork_child(pos, left_pipe, right_pipe, argv);

        // Only the parent will return here!!!

        num_of_commands++;

        // The previous rigth pipe now becomes the current left pipe.
        shift_pipes(left_pipe, right_pipe);


    } while (pos != single && pos != last);

    return num_of_commands;
}
开发者ID:lingmar,项目名称:os16,代码行数:33,代码来源:shell.c

示例7: vloopback_open

static int vloopback_open(struct file *f)
#endif
{    
    struct video_device *loopdev = video_devdata(f);
    
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)    
    priv_ptr ptr = (priv_ptr)dev_get_drvdata(&loopdev->dev);
#else
    priv_ptr ptr = (priv_ptr)loopdev->vd_private_data;
#endif    
    int nr = ptr->pipenr;

    if (debug > LOG_NODEBUG)
        info("Video loopback %d", nr);    

    /* Only allow a output to be opened if there is someone feeding
     * the pipe.
     */
    if (!ptr->in) {
        if (loops[nr]->buffer == NULL) 
            return -EINVAL;
        
        loops[nr]->framesread = 0;
        loops[nr]->ropen = 1;
    } else {
        if (loops[nr]->ropen || loops[nr]->wopen) 
            return -EBUSY;

        loops[nr]->framesdumped = 0;
        loops[nr]->frameswrite = 0;
        loops[nr]->wopen = 1;
        loops[nr]->zerocopy = 0;
        loops[nr]->ioctlnr = -1;
        pipesused++;
        if (nr_o_pipes-pipesused<spares) {
            if (!create_pipe(nr_o_pipes)) {
                info("Creating extra spare pipe");
                info("Loopback %d registered, input: video%d, output: video%d",
                    nr_o_pipes,
                    loops[nr_o_pipes]->vloopin->minor,
                    loops[nr_o_pipes]->vloopout->minor
                );
                nr_o_pipes++;
            }
        }
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
        loops[nr]->pid = current->pid;
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)        
        loops[nr]->pid = find_vpid(current->pid);
#else
        // TODO : Check in stable 2.6.27
        loops[nr]->pid = task_pid(find_task_by_vpid(current->pid));
        //loops[nr]->pid = task_pid(current);
#endif        

        if (debug > LOG_NODEBUG)
            info("Current pid %d", current->pid);
    }
    return 0;
}
开发者ID:rfajardo,项目名称:devmech,代码行数:60,代码来源:vloopback.c

示例8: CreateNamedPipe

void WinListener::create_pipe()
{
    _pipe = CreateNamedPipe(_pipename, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
                            PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
                            PIPE_UNLIMITED_INSTANCES, PIPE_BUF_SIZE, PIPE_BUF_SIZE,
                            PIPE_TIMEOUT, NULL);
    if (_pipe == INVALID_HANDLE_VALUE) {
        THROW("CreateNamedPipe() failed %u", GetLastError());
    }
    if (ConnectNamedPipe(_pipe, &_overlap)) {
        THROW("ConnectNamedPipe() is not pending");
    }
    switch (GetLastError()) {
    case ERROR_IO_PENDING:
        DBG(0, "Pipe waits for connection");
        break;
    case ERROR_PIPE_CONNECTED: {
        DBG(0, "Pipe already connected");
        WinConnection *con = new WinConnection(_pipe, _process_loop);
        NamedPipe::ConnectionInterface &con_interface = _listener_interface.create();
        con->set_handler(&con_interface);
        con_interface.bind((NamedPipe::ConnectionRef)con);
        create_pipe();
        break;
    }
    default:
        THROW("ConnectNamedPipe() failed %u", GetLastError());
    }
}
开发者ID:colama,项目名称:colama-3rdparty-tools,代码行数:29,代码来源:named_pipe.cpp

示例9: check_ops

int     check_ops(char *str, t_tree *tree)
{
  if (tree->parent != NULL)
    {
      if ((my_strcmp(tree->parent->str, ">") == 0
           || my_strcmp(tree->parent->str, ">>") == 0)
          && tree == tree->parent->right)
        return (0);
      if ((my_strcmp(tree->parent->str, "<") == 0)
          && tree == tree->parent->right)
        return (0);
    }
  if (my_strcmp(str, ";") == 0)
    return (0);
  else if (my_strcmp(str, "&&") == 0)
    return (0);
  else if (my_strcmp(str, "||") == 0)
    return (0);
  else if (my_strcmp(str, "|") == 0)
    {
      create_pipe(tree);
      return (0);
    }
  else
    return (check_ops2(str, tree));
}
开发者ID:Vuldo,项目名称:42sh,代码行数:26,代码来源:exec.c

示例10: main

int main(int argc, char* argv[]) {
	int n,i;
	int last_pipe[2];
    struct grammar g;

	if (argc != 4) {
		fatal("Usage: %s <workers number> <grammar file> <starting symbol>\n",
            argv[0]);
	}
	n = atoi(argv[1]);
	if (n <= 0) {
		fatal("Number of workers should be a positive integer");
	}
    if (strlen(argv[3]) != 1 || !is_upper(argv[3][0])) {
        fatal("Starting symbol should be a single nonterminal (uppercase)\n");
    }

    create_pipe(last_pipe);
	make_loop(n, last_pipe, argv[2]);

    read_grammar(&g, argv[2]);
    work(&g, argv[3][0]);

    for (i = 1; i < n; i++) {
		if (wait(0) == -1) syserr("Error in wait()\n");
	}
	return 0;
}
开发者ID:ertesh,项目名称:SO,代码行数:28,代码来源:manager.c

示例11: exec_a_pipe

int	exec_a_pipe(t_sh *shell, t_grp *grp)
{
  t_fds	fd;
  int	ptab[2];
  t_cmd	*tmpcmd;
  int	i;

  i = 0;
  ptab[PIPE_READ] = -1;
  ptab[PIPE_WRITE] = -1;
  init_stdfd_t_def_val(&fd, grp->fd.stdin, grp->fd.stdout, grp->fd.stderr);
  if (grp->cmds == NULL)
    return (-1);
  while ((tmpcmd = grp->cmds[i]) != NULL)
    {
      if (create_pipe(grp, ptab, &fd, i) == -1)
        return (-1);
      cmd_execution(tmpcmd, &fd, shell);
      if (MEXIT)
        return (0);
      group_to_process_group(grp, tmpcmd);
      init_stdfd_t_def_val(&fd, grp->fd.stdin, grp->fd.stdout, grp->fd.stderr);
      if (grp->cmds[i + 1] != NULL)
        fd.stdin = ptab[PIPE_READ];
      i++;
    }
  return (0);
}
开发者ID:Tastyep,项目名称:42sh,代码行数:28,代码来源:pipe.c

示例12: create_cube

void ShZshapeManager::create_shape(const char* content)
{
	if (content == "cube")
	{
		create_cube();
	}

	if (content == "cylinder")
	{
		create_cylinder();
	}

	if (content == "pipe")
	{
		create_pipe();
	}

	if (content == "cone")
	{
		create_cone();
	}

	if (content == "circle")
	{
		create_circle();
	}

	if (content == "ring")
	{
		create_ring();
	}

	if (content == "pyramid")
	{
		create_pyramid();
	}

	if (content == "triangle")
	{
		create_triangle();
	}

	if (content == "rectangle")
	{
		create_rectangle();
	}

	if (content == "polygon")
	{
		create_polygon();
	}

	if (content == "multigonalStar")
	{
		create_multigonalStar();
	}

}
开发者ID:shuaihuzhou,项目名称:openglExample,代码行数:58,代码来源:ShZshapeManager.cpp

示例13: create_pipes

// This method creates the named pipes used to communicate with the webservice
void create_pipes() {
	char nomepipe[1024];

	// This file will contain the username of the user to be authenticated
	sprintf(nomepipe, "%s%s", PREFIX, sessionID);
	write_file(&nomepipe[0], username, 1);

	// This pipe contains the text of the question to be presented to the user
	sprintf(nomepipe, "%s%s_testo", PREFIX, sessionID);
	create_pipe(&nomepipe[0]);

	// This pipe contains the type of the question to be presented to the user
	sprintf(nomepipe, "%s%s_tipo", PREFIX, sessionID);
	create_pipe(&nomepipe[0]);

	// This pipe is used to collect the response of the user to the question
	sprintf(nomepipe, "%s%s_risposta", PREFIX, sessionID);
	create_pipe(&nomepipe[0]);
}
开发者ID:biancini,项目名称:SMS-Authentication,代码行数:20,代码来源:pamwrap.c

示例14: create_pipe

void tester_util::redirect(const ProcessPointer &from, const int from_fd,
                           const ProcessPointer &to, const int to_fd) {
  try {
    const Pipe pipe = create_pipe();
    from->setStream(from_fd, pipe.writeEnd());
    to->setStream(to_fd, pipe.readEnd());
  } catch (std::exception &) {
    BOOST_THROW_EXCEPTION(redirect_error() << bunsan::enable_nested_current());
  }
}
开发者ID:bacsorg,项目名称:system_single,代码行数:10,代码来源:tester_util.cpp

示例15: spawn_sorts

/* creates an array containing all the PIDs of the child processes */
void spawn_sorts(int **in_pipe, int **out_pipe)
{
	//Spawn all the sort processes
	process_array = malloc(sizeof(pid_t) * num_sorts);
	pid_t pid;
        int i;
        for (i = 0; i < num_sorts; i++){
                create_pipe(in_pipe[i]);
                create_pipe(out_pipe[i]);  
                switch(pid = fork()){
                        case -1: //Oops case
                                puke_and_exit("Forking error\n");
                        case 0: //Child case
			        close(STDIN_FILENO);
			        close(STDOUT_FILENO);
			        if (in_pipe[i][0] != STDIN_FILENO) {	//Defensive check
					if (dup2(in_pipe[i][0], STDIN_FILENO) ==
					    -1)
						puke_and_exit("dup2 0");
				}
				/* Bind stdout to out_pipe*/
				close_pipe(out_pipe[i][0]);	//close read end of output pipe
				if (out_pipe[i][1] != STDOUT_FILENO) {	//Defensive check
					if (dup2(out_pipe[i][1], STDOUT_FILENO) ==
					    -1)
						puke_and_exit("dup2 1");
				}
                                /* 
                                Pipes from previously-spawned children are still open in this child
                                Close them and close the duplicate pipes just created by dup2 
                                */
                                close_pipes_array(in_pipe, i+1);
                                close_pipes_array(out_pipe, i+1);
                                execlp("sort", "sort", (char *)NULL);
                        default: //Parent case
                                process_array[i] = pid;
                                close_pipe(in_pipe[i][0]);
                		close_pipe(out_pipe[i][1]);
                                break; 
                }
        }
}
开发者ID:davidmerrick,项目名称:Classes,代码行数:43,代码来源:uniqify.c


注:本文中的create_pipe函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。