• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ chancreate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: pipeline

int
pipeline(int fd, char *cmd, ...)
{
    Exec *e;
    va_list a;

    e = emalloc(sizeof(Exec));
    if(pipe(e->p)<0 || pipe(e->q)<0)
        error("can't create pipe");
    close(e->p[0]);
    e->p[0] = fd;
    va_start(a, cmd);
    e->cmd = vsmprint(cmd, a);
    va_end(a);
    e->sync = chancreate(sizeof(ulong), 0);
    if(e->sync == nil)
        error("can't create channel");
    proccreate(execproc, e, STACK);
    recvul(e->sync);
    chanfree(e->sync);
    free(e->cmd);
    close(e->p[0]);
    close(e->p[1]);
    close(e->q[1]);
    fd = e->q[0];
    free(e);
    return fd;
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:28,代码来源:util.c


示例17: newconn

static Conn*
newconn(Ether *e)
{
	int i;
	Conn *c;

	qlock(e);
	for(i = 0; i < nelem(e->conns); i++){
		c = e->conns[i];
		if(c == nil || c->ref == 0){
			if(c == nil){
				c = emallocz(sizeof(Conn), 1);
				c->rc = chancreate(sizeof(Buf*), 16);
				c->nb = i;
			}
			c->ref = 1;
			if(i == e->nconns)
				e->nconns++;
			e->conns[i] = c;
			deprint(2, "%s: newconn %d\n", argv0, i);
			qunlock(e);
			return c;
		}
	}
	qunlock(e);
	return nil;
}
开发者ID:npe9,项目名称:harvey,代码行数:27,代码来源:ether.c


示例18: threadwaitchan

Channel*
threadwaitchan(void)
{
	if(_threadwaitchan==nil)
		_threadwaitchan = chancreate(sizeof(Waitmsg*), 16);
	return _threadwaitchan;
}
开发者ID:CoryXie,项目名称:nix-os,代码行数:7,代码来源:exit.c


示例19: main

int
main(void)
{
	int i, nprocs, procn[Nproc];
	
	fail = 0;
	nprocs = 0;
	ch = chancreate(1000, sizeof(int));
	if(ch == nil){
		fail = 1;
		printf("chancreate failed\n");
	}
		
	for(i = 0; i < Nproc; ++i){
		procn[i] = i + 1;
		if(proccreate(f, &procn[i], 0) == nil){
			fail = 1;
			printf("proccreate failed\n");
		}else{
			nprocs++;
		}
	}
	
	for(i = 0; i < nprocs; ++i){
		int n;
		
		if(chanrecv(ch, &n) != 1){
			fail = 1;
			printf("recv error\n");
		}
	}
	chanfree(ch);
	return fail;
}
开发者ID:icanhas,项目名称:libccco,代码行数:34,代码来源:spawnexit.c


示例20: extstart

void
extstart(void)
{
	char buf[32];
	int fd;
	static int p[2];
	static void *arg[2];

	if(pipe(p) < 0)
		return;
	sprint(exname, "/srv/sam.%s", getuser());
	fd = create(exname, 1, 0600);
	if(fd < 0){	/* assume existing guy is more important */
    Err:
		close(p[0]);
		close(p[1]);
		return;
	}
	sprint(buf, "%d", p[0]);
	if(write(fd, buf, strlen(buf)) <= 0)
		goto Err;
	close(fd);
	/*
	 * leave p[0] open so if the file is removed the event
	 * library won't get an error
	 */
	plumbc = chancreate(sizeof(int), 0);
	arg[0] = plumbc;
	arg[1] = &p[1];
	proccreate(extproc, arg, 1024);
	atexit(removeextern);
}
开发者ID:dancrossnyc,项目名称:harvey,代码行数:32,代码来源:plan9.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ change函数代码示例发布时间:2022-05-30
下一篇:
C++ chan函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap