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


C++ chancreate函数代码示例

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


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

示例1: sunsrvudp

int
sunsrvudp(SunSrv *srv, char *address)
{
	int fd;
	char adir[40];
	Arg *arg;

	fd = announce(address, adir);
	if(fd < 0)
		return -1;

	arg = emalloc(sizeof(Arg));
	arg->fd = fd;
	arg->srv = srv;
	arg->creply = chancreate(sizeof(SunMsg*), 10);
	arg->csync = chancreate(sizeof(void*), 10);

	proccreate(sunudpread, arg, SunStackSize);
	proccreate(sunudpwrite, arg, SunStackSize);
	recvp(arg->csync);
	recvp(arg->csync);
	chanfree(arg->csync);
	free(arg);

	return 0;
}
开发者ID:00001,项目名称:plan9port,代码行数:26,代码来源:udp.c

示例2: threadmain

void
threadmain(int argc, char *argv[])
{
	char m[48];
	int t;
	Alt a[] = {
	/*	 c		v		op   */
		{nil,	m,	CHANRCV},
		{nil,	&t,	CHANRCV},
		{nil,	nil,	CHANEND},
	};

	/* create mouse event channel and mouse process */
	a[0].c = chancreate(sizeof m, 0);
	proccreate(mouseproc, a[0].c, STACK);

	/* create clock event channel and clock process */
	a[1].c = chancreate(sizeof(ulong), 0);	/* clock event channel */
	proccreate(clockproc, a[1].c, STACK);

	for(;;){
		switch(alt(a)){
		case 0:	/*mouse event */
			fprint(2, "click ");
			break;
		case 1:	/* clock event */
			fprint(2, "tic ");
			break;
		default:
			sysfatal("can't happen");
		}
	}
}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:33,代码来源:example.c

示例3: listenthread

void
listenthread(void *arg)
{
	Conn *c;
	Ioproc *io;

	io = ioproc();
	USED(arg);
	threadsetname("listen %s", adir);
	for(;;){
		c = emalloc(sizeof(Conn));
		c->fd = iolisten(io, adir, c->dir);
		if(c->fd < 0){
			if(verbose) fprint(2, "%T listen: %r\n");
			close(afd);
			free(c);
			return;
		}
		c->inc = chancreate(sizeof(void*), 0);
		c->internal = chancreate(sizeof(void*), 0);
		c->inq = qalloc();
		c->outq = qalloc();
		c->outqdead = chancreate(sizeof(void*), 0);
		if(verbose) fprint(2, "%T incoming call on %s\n", c->dir);
		threadcreate(connthread, c, STACK);
	}	
}
开发者ID:00001,项目名称:plan9port,代码行数:27,代码来源:9pserve.c

示例4: startbloomproc

void
startbloomproc(Bloom *b)
{
	b->writechan = chancreate(sizeof(void*), 0);
	b->writedonechan = chancreate(sizeof(ulong), 0);
	vtproc(bloomwriteproc, b);	
}
开发者ID:bbarker,项目名称:plan9,代码行数:7,代码来源:bloom.c

示例5: xopenfd

int
xopenfd(Msg *m)
{
	char errs[ERRMAX];
	int n, p[2];
	Conn *nc;

	if(pipe(p) < 0){
		rerrstr(errs, sizeof errs);
		err(m, errs);
		/* XXX return here? */
	}
	if(verbose) fprint(2, "%T xopen pipe %d %d...", p[0], p[1]);

	/* now we're committed. */

	/* a new connection for this fid */
	nc = emalloc(sizeof(Conn));
	nc->internal = chancreate(sizeof(void*), 0);

	/* a ref for us */
	nc->fdfid = m->fid;
	m->fid->ref++;
	nc->fdfid->openfd++;
	nc->fdmode = m->tx.mode;
	nc->fd = p[0];

	/* a thread to tend the pipe */
	threadcreate(openfdthread, nc, STACK);

	/* if mode is ORDWR, that openfdthread will write; start a reader */
	if((m->tx.mode&3) == ORDWR){
		nc = emalloc(sizeof(Conn));
		nc->internal = chancreate(sizeof(void*), 0);
		nc->fdfid = m->fid;
		m->fid->ref++;
		nc->fdfid->openfd++;
		nc->fdmode = OREAD;
		nc->fd = dup(p[0], -1);
		threadcreate(openfdthread, nc, STACK);
	}

	/* steal fid from other connection */
	if(delhash(m->c->fid, m->fid->cfid, m->fid) == 0)
		fidput(m->fid);

	/* rewrite as Ropenfd */
	m->rx.type = Ropenfd;
	n = GBIT32(m->rpkt);
	m->rpkt = erealloc(m->rpkt, n+4);
	PBIT32(m->rpkt+n, p[1]);
	n += 4;
	PBIT32(m->rpkt, n);
	m->rpkt[4] = Ropenfd;
	m->rx.unixfd = p[1];
	return 0;
}
开发者ID:00001,项目名称:plan9port,代码行数:57,代码来源:9pserve.c

示例6: threadmain

void
threadmain(int argc, char **argv)
{
	uintptr_t pid;
	char *cmd = nil;
	char **args = nil;

	/*
	 * don't bother with fancy arg processing, because it picks up options
	 * for the command you are starting.  Just check for -c as argv[1]
	 * and then take it from there.
	 */
	if (argc < 2)
		usage();
	while (argv[1][0] == '-') {
		switch(argv[1][1]) {
		case 'c':
			if (argc < 3)
				usage();
			cmd = strdup(argv[2]);
			args = &argv[2];
			break;
		case 'd':
			debug = 1;
			break;
		default:
			usage();
		}
		++argv;
		--argc;
	}

	/* run a command? */
	if(cmd) {
		pid = fork();
		if (pid < 0)
			sysfatal("fork failed: %r");
		if(pid == 0) {
			hang();
			exec(cmd, args);
			if(cmd[0] != '/')
				exec(smprint("/bin/%s", cmd), args);
			sysfatal("exec %s failed: %r", cmd);
		}
	} else {
		if(argc != 2)
			usage();
		pid = atoi(argv[1]);
	}

	out   = chancreate(sizeof(char*), 0);
	quit  = chancreate(sizeof(char*), 0);
	forkc = chancreate(sizeof(uint32_t *), 0);
	nread++;
	procrfork(writer, nil, Stacksize, 0);
	reader((void*)pid);
}
开发者ID:dalmonian,项目名称:harvey,代码行数:57,代码来源:ratrace.c

示例7: mountcons

void
mountcons(void)
{
	fschan = chancreate(sizeof(Fsevent), 0);
	writechan = chancreate(sizeof(void*), 0);
	fs.tree = alloctree("win", "win", DMDIR|0555, nil);
	devcons = createfile(fs.tree->root, "cons", "win", 0666, nil);
	if(devcons == nil)
		sysfatal("creating /dev/cons: %r");
	devnew = createfile(fs.tree->root, "wnew", "win", 0666, nil);
	if(devnew == nil)
		sysfatal("creating /dev/wnew: %r");
	threadpostmountsrv(&fs, nil, "/dev", MBEFORE);
}
开发者ID:bhanug,项目名称:harvey,代码行数:14,代码来源:fs.c

示例8: sunSrv

SunSrv*
sunSrv(void)
{
	SunSrv *srv;

	srv = emalloc(sizeof(SunSrv));
	srv->chatty = 0;
	srv->crequest = chancreate(sizeof(SunMsg*), 16);
	srv->creply = chancreate(sizeof(SunMsg*), 16);
	srv->cthread = chancreate(sizeof(Targ), 4);

	proccreate(sunRpcProc, srv, SunStackSize);
	return srv;
}
开发者ID:99years,项目名称:plan9,代码行数:14,代码来源:server.c

示例9: startplumbing

void
startplumbing(void)
{
	cplumb = chancreate(sizeof(Plumbmsg*), 0);
	chansetname(cplumb, "cplumb");
	threadcreate(plumbthread, nil, STACK);
}
开发者ID:9fans,项目名称:plan9port,代码行数:7,代码来源:look.c

示例10: plumbstart

void
plumbstart(void)
{
	plumbchan = chancreate(sizeof(Plumbmsg*), 0);
	proccreate(plumbwebproc, nil, STACK);
	threadcreate(plumbwebthread, nil, STACK);
}
开发者ID:99years,项目名称:plan9,代码行数:7,代码来源:plumb.c

示例11: hoststart

void
hoststart(void)
{
	hostc = chancreate(sizeof(int), 0);
	chansetname(hostc, "hostc");
	proccreate(hostproc, hostc, STACK);
}
开发者ID:00001,项目名称:plan9port,代码行数:7,代码来源:plan9.c

示例12: twaitinit

void
twaitinit(void)
{
	threadwaitchan();	/* allocate it before returning */
	twaitchan = chancreate(sizeof(Waitreq), 10);
	threadcreate(waitthread, nil, 128*1024);
}
开发者ID:00001,项目名称:plan9port,代码行数:7,代码来源:wait.c

示例13: initicachewrite

void
initicachewrite(void)
{
	int i;
	Index *ix;

	initround(&iwrite.round, "icache", 120*60*1000);
	ix = mainindex;
	for(i=0; i<ix->nsects; i++){
		ix->sects[i]->writechan = chancreate(sizeof(ulong), 1);
		ix->sects[i]->writedonechan = chancreate(sizeof(ulong), 1);
		vtproc(icachewriteproc, ix->sects[i]);
	}
	vtproc(icachewritecoord, nil);
	vtproc(delaykickroundproc, &iwrite.round);
}
开发者ID:00001,项目名称:plan9port,代码行数:16,代码来源:icachewrite.c

示例14: execthread

static void
execthread(void *a)
{
	Client *c;
	int p;
	char tmp[32];

	c = a;
	snprint(tmp, sizeof tmp, "exec%d", c->num);
	threadsetname(tmp);
	c->execpid = chancreate(sizeof(ulong), 0);
	proccreate(execproc, c, STACK);
	p = recvul(c->execpid);
	chanfree(c->execpid);
	c->execpid = nil;
	close(c->fd[1]);
	c->fd[1] = c->fd[0];
	if(p != -1){
		c->pid = p;
		c->activethread = 2;
		threadcreate(readthread, c, STACK);
		threadcreate(writethread, c, STACK);
		if(c->execreq)
			respond(c->execreq, nil);
	}else{
		if(c->execreq)
			respond(c->execreq, c->err);
	}
}
开发者ID:rminnich,项目名称:harvey,代码行数:29,代码来源:client.c

示例15: startpipe

void
startpipe(void)
{
	newpipechan = chancreate(sizeof(Window*), 0);
	threadcreate(newpipethread, nil, STACK);
	snarffd = open("/dev/snarf", OREAD|OCEXEC);
}
开发者ID:CoryXie,项目名称:nix-os,代码行数:7,代码来源:pipe.c


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