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


C++ wunlock函数代码示例

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


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

示例1: ipifcconnect

/*
 *  associate an address with the interface.  This wipes out any previous
 *  addresses.  This is a macro that means, remove all the old interfaces
 *  and add a new one.
 */
static char*
ipifcconnect(Conv* c, char **argv, int argc)
{
	Proc *up = externup();
	char *err;
	Ipifc *ifc;

	ifc = (Ipifc*)c->ptcl;

	if(ifc->medium == nil)
		 return "ipifc not yet bound to device";

	if(waserror()){
		wunlock(ifc);
		nexterror();
	}
	wlock(ifc);
	while(ifc->lifc){
		err = ipifcremlifc(ifc, ifc->lifc);
		if(err)
			error(err);
	}
	wunlock(ifc);
	poperror();

	err = ipifcadd(ifc, argv, argc, 0, nil);
	if(err)
		return err;

	Fsconnected(c, nil);
	return nil;
}
开发者ID:qioixiy,项目名称:harvey,代码行数:37,代码来源:ipifc.c

示例2: closepgrp

void
closepgrp(Pgrp *p)
{
	Mhead **h, **e, *f, *next;

	if(decref(&p->ref) != 0)
		return;

	qlock(&p->debug);
	wlock(&p->ns);
	p->pgrpid = -1;

	e = &p->mnthash[MNTHASH];
	for(h = p->mnthash; h < e; h++) {
		for(f = *h; f; f = next) {
			wlock(&f->lock);
			cclose(f->from);
			mountfree(f->mount);
			f->mount = nil;
			next = f->hash;
			wunlock(&f->lock);
			putmhead(f);
		}
	}
	wunlock(&p->ns);
	qunlock(&p->debug);
	free(p);
}
开发者ID:0intro,项目名称:drawterm,代码行数:28,代码来源:pgrp.c

示例3: ERRSTACK

/*
 *  associate an address with the interface.  This wipes out any previous
 *  addresses.  This is a macro that means, remove all the old interfaces
 *  and add a new one.
 */
static char *ipifcconnect(struct conv *c, char **argv, int argc)
{
	ERRSTACK(1);
	char *err;
	struct Ipifc *ifc;

	ifc = (struct Ipifc *)c->ptcl;

	if (ifc->m == NULL)
		return "ipifc not yet bound to device";

	if (waserror()) {
		wunlock(&ifc->rwlock);
		nexterror();
	}
	wlock(&ifc->rwlock);
	while (ifc->lifc) {
		err = ipifcremlifc(ifc, ifc->lifc);
		if (err)
			error(err);
	}
	wunlock(&ifc->rwlock);
	poperror();

	err = ipifcadd(ifc, argv, argc, 0, NULL);
	if (err)
		return err;

	Fsconnected(c, NULL);

	return NULL;
}
开发者ID:7perl,项目名称:akaros,代码行数:37,代码来源:ipifc.c

示例4: devlogfssetdefname

static Devlogfs *
devlogfssetdefname(char *name)
{
	Devlogfs *l;
	char *searchname;
	wlock(&devlogfslist.rwlock);
	if (waserror()) {
		wunlock(&devlogfslist.rwlock);
		nexterror();
	}
	if (name == nil)
		searchname = devlogfslist.defname;
	else
		searchname = name;
	for (l = devlogfslist.head; l; l = l->next)
		if (strcmp(l->name, searchname) == 0)
			break;
	if (l == nil) {
		logfsfreemem(devlogfslist.defname);
		devlogfslist.defname = nil;
	}
	else if (name) {
		if (devlogfslist.defname) {
			logfsfreemem(devlogfslist.defname);
			devlogfslist.defname = nil;
		}
		devlogfslist.defname = estrdup(name);
	}
	poperror();
	wunlock(&devlogfslist.rwlock);
	return l;
}
开发者ID:8l,项目名称:inferno,代码行数:32,代码来源:devlogfs.c

示例5: _MemoryRealloc

// ---
tERROR pr_call _MemoryRealloc( tPO* po, tHANDLE* handle, tDWORD size ) {

  tOBJECT* obj;
  tERROR   error;
  PR_TRACE_A0( MakeObject(handle), "Enter _MemoryRealloc" );

  if ( handle->obj == NULL ) {  // alloc new memory
		error = PrAlloc( (tPTR*)&obj, sizeof(tOBJECT) + size );
    if ( PR_SUCC(error) ) {
      wlock(po);
      handle->obj = obj;
      _ObjectInit0( handle );
      wunlock(po);
    }
  }

  else {
    wlock(po);
    if ( PR_SUCC(error=PrRealloc((tPTR*)&handle->obj,handle->obj,sizeof(tOBJECT)+size)) ) {
      *odata(handle->obj) = handle->obj + 1;
    }
    wunlock(po);
  }

  PR_TRACE_A1( MakeObject(handle), "Leave _MemoryRealloc ret %terr", error );
  return error;
}
开发者ID:hackshields,项目名称:antivirus,代码行数:28,代码来源:sys_mem.c

示例6: gencurrent

static void
gencurrent(Wcache *w, Qid *q, char *file, char *lock, uint32_t *t,
	   Whist **wp, int n)
{
	Dir *d;
	Whist *wh;

	if(*wp && *t+Tcache >= time(0))
		return;

	wlock(w);
	if(*wp && *t+Tcache >= time(0)){
		wunlock(w);
		return;
	}

	if(((d = wdirstat(file)) == nil) || (d->qid.path==q->path && d->qid.vers==q->vers)){
		*t = time(0);
		wunlock(w);
		free(d);
		return;
	}

	free(d);
	if(wh = readwhist(file, lock, q)){
		wh->n = n;
		*t = time(0);
		closewhist(*wp);
		*wp = wh;
	}
else fprint(2, "error file=%s lock=%s %r\n", file, lock);
	wunlock(w);
}
开发者ID:bhanug,项目名称:harvey,代码行数:33,代码来源:io.c

示例7: consopen

static Chan*
consopen(Chan *c, int omode)
{
	c->aux = 0;
	switch((ulong)c->qid.path){
	case Qconsctl:
		if(!iseve())
			error(Eperm);
		qlock(&kbd);
		kbd.ctl++;
		qunlock(&kbd);
		break;

	case Qkeyboard:
		if((omode & 3) != OWRITE) {
			qlock(&kbd);
			kbd.kbdr++;
			flushkbdline(kbdq);
			kbd.raw = 1;
			qunlock(&kbd);
		}
		break;

	case Qscancode:
		qlock(&kbd);
		if(kscanq || !kscanid) {
			qunlock(&kbd);
			c->flag &= ~COPEN;
			if(kscanq)
				error(Einuse);
			else
				error(Ebadarg);
		}
		kscanq = qopen(256, 0, nil, nil);
		qunlock(&kbd);
		break;

	case Qkprint:
		if((omode & 3) != OWRITE) {
			wlock(&kprintq);
			if(kprintq.q != nil){
				wunlock(&kprintq);
				error(Einuse);
			}
			kprintq.q = qopen(32*1024, Qcoalesce, nil, nil);
			if(kprintq.q == nil){
				wunlock(&kprintq);
				error(Enomem);
			}
			qnoblock(kprintq.q, 1);
			wunlock(&kprintq);
			c->iounit = qiomaxatomic;
		}
		break;
	}
	return devopen(c, omode, consdir, nelem(consdir), devgen);
}
开发者ID:8l,项目名称:inferno,代码行数:57,代码来源:devcons.c

示例8: devream

void
devream(Device *d, int top)
{
	Device *l;

loop:
	print("\tdevream: %Z %d\n", d, top);
	switch(d->type) {
	default:
		print("ream: unknown dev type %Z\n", d);
		return;

	case Devcw:
		devream(d->cw.w, 0);
		devream(d->cw.c, 0);
		if(top) {
			wlock(&mainlock);
			cwream(d);
			wunlock(&mainlock);
		}
		devinit(d);
		return;

	case Devfworm:
		devream(d->fw.fw, 0);
		fwormream(d);
		break;

	case Devpart:
		devream(d->part.d, 0);
		break;

	case Devmlev:
	case Devmcat:
	case Devmirr:
		for(l=d->cat.first; l; l=l->link)
			devream(l, 0);
		break;

	case Devjuke:
	case Devworm:
	case Devlworm:
	case Devwren:
		break;

	case Devswab:
		d = d->swab.d;
		goto loop;
	}
	devinit(d);
	if(top) {
		wlock(&mainlock);
		rootream(d, ROOT_ADDR);
		superream(d, SUPER_ADDR);
		wunlock(&mainlock);
	}
}
开发者ID:npe9,项目名称:harvey,代码行数:57,代码来源:sub.c

示例9: consopen

Chan*
consopen(Chan *c, int omode)
{
	c = devopen(c, omode, contab, nelem(contab), devgen);
	switch((ulong)c->qid.path) {
	case Qconsctl:
		incref(&kbd.ctl);
		break;
	case Qpointer:
		if(incref(&kbd.ptr) != 1){
			decref(&kbd.ptr);
			c->flag &= ~COPEN;
			error(Einuse);
		}
		break;
	case Qscancode:
		qlock(&kbd.gq);
		if(gkscanq || !gkscanid) {
			qunlock(&kbd.q);
			c->flag &= ~COPEN;
			if(gkscanq)
				error(Einuse);
			else
				error(Ebadarg);
		}
		gkscanq = qopen(256, 0, nil, nil);
		qunlock(&kbd.gq);
		break;
	case Qkprint:
		wlock(&kprintq.l);
		if(kprintq.q != nil){
			wunlock(&kprintq.l);
			c->flag &= ~COPEN;
			error(Einuse);
		}
		kprintq.q = qopen(32*1024, 0, 0, 0);
		if(kprintq.q == nil){
			wunlock(&kprintq.l);
			c->flag &= ~COPEN;
			error(Enomem);
		}
		qnoblock(kprintq.q, 1);
		wunlock(&kprintq.l);
		break;
	case Qsnarf:
		if(omode == ORDWR)
			error(Eperm);
		if(omode == OREAD)
			c->aux = strdup("");
		else
			c->aux = mallocz(SnarfSize, 1);
		break;
	}
	return c;
}
开发者ID:caerwynj,项目名称:inferno-lab,代码行数:55,代码来源:devcons.c

示例10: envcreate

static Chan*
envcreate(Chan *c, char *name, int omode, ulong)
{
	Egrp *eg;
	Evalue *e;
	Evalue **ent;

	if(c->qid.type != QTDIR || !envwriteable(c))
		error(Eperm);

	if(strlen(name) >= sizeof(up->genbuf))
		error(Etoolong);

	omode = openmode(omode);
	eg = envgrp(c);

	wlock(eg);
	if(waserror()) {
		wunlock(eg);
		nexterror();
	}

	if(envlookup(eg, name, -1) != nil)
		error(Eexist);

	e = smalloc(sizeof(Evalue));
	e->name = smalloc(strlen(name)+1);
	strcpy(e->name, name);

	if(eg->nent == eg->ment){
		eg->ment += 32;
		ent = smalloc(sizeof(eg->ent[0])*eg->ment);
		if(eg->nent)
			memmove(ent, eg->ent, sizeof(eg->ent[0])*eg->nent);
		free(eg->ent);
		eg->ent = ent;
	}
	e->qid.path = ++eg->path;
	e->qid.vers = 0;
	eg->vers++;
	eg->ent[eg->nent++] = e;
	c->qid = e->qid;

	wunlock(eg);
	poperror();

	c->offset = 0;
	c->mode = omode;
	c->flag |= COPEN;
	return c;
}
开发者ID:Nurb432,项目名称:plan9front,代码行数:51,代码来源:devenv.c

示例11: envcreate

static Chan*
envcreate(Chan *c, char *name, int omode, ulong)
{
	Egrp *eg;
	Evalue *e;

	if(c->qid.type != QTDIR || !envwriteable(c))
		error(Eperm);

	if(strlen(name) >= sizeof(up->genbuf))
		error(Etoolong);

	omode = openmode(omode);
	eg = envgrp(c);
	wlock(eg);
	if(waserror()) {
		wunlock(eg);
		nexterror();
	}

	if(envlookup(eg, name, -1) != nil)
		error(Eexist);

	if(eg->nent == eg->ment){
		Evalue *tmp;

		eg->ment += DELTAENV;
		if((tmp = realloc(eg->ent, sizeof(eg->ent[0])*eg->ment)) == nil){
			eg->ment -= DELTAENV;
			error(Enomem);
		}
		eg->ent = tmp;
	}
	eg->vers++;
	e = &eg->ent[eg->nent++];
	e->value = nil;
	e->len = 0;
	e->name = smalloc(strlen(name)+1);
	strcpy(e->name, name);
	mkqid(&e->qid, ++eg->path, 0, QTFILE);
	c->qid = e->qid;

	wunlock(eg);
	poperror();

	c->offset = 0;
	c->mode = omode;
	c->flag |= COPEN;
	return c;
}
开发者ID:srk-cmu,项目名称:9problems,代码行数:50,代码来源:devenv.c

示例12: envcreate

static void
envcreate(Chan *c, char *name, int omode, int i)
{
	Proc *up = externup();
	Egrp *eg;
	Evalue *e;
	Evalue **ent;

	if(c->qid.type != QTDIR)
		error(Eperm);

	omode = openmode(omode);
	eg = envgrp(c);

	wlock(&eg->rwl);
	if(waserror()) {
		wunlock(&eg->rwl);
		nexterror();
	}

	if(envlookup(eg, name, -1))
		error(Eexist);

	e = smalloc(sizeof(Evalue));
	e->name = smalloc(strlen(name)+1);
	strcpy(e->name, name);

	if(eg->nent == eg->ment){
		eg->ment += 32;
		ent = smalloc(sizeof(eg->ent[0])*eg->ment);
		if(eg->nent)
			memmove(ent, eg->ent, sizeof(eg->ent[0])*eg->nent);
		free(eg->ent);
		eg->ent = ent;
	}
	e->qid.path = ++eg->path;
	e->qid.vers = 0;
	eg->vers++;
	eg->ent[eg->nent++] = e;
	c->qid = e->qid;

	wunlock(&eg->rwl);
	poperror();

	c->offset = 0;
	c->mode = omode;
	c->flag |= COPEN;
}
开发者ID:Requaos,项目名称:harvey,代码行数:48,代码来源:devenv.c

示例13: wlock

const char *GetLastErrorMsg(void)
{
	static unsigned int lock = 0;
	wlock(&lock);
    static TCHAR szBuf[256]; 
    LPVOID lpMsgBuf;
    DWORD dw = GetLastError(); 

    FormatMessage(
        FORMAT_MESSAGE_ALLOCATE_BUFFER | 
        FORMAT_MESSAGE_FROM_SYSTEM,
        NULL,
        dw,
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPTSTR) &lpMsgBuf,
        0, NULL );

	char *p;
	while ( (p=strchr((char*)lpMsgBuf,'\n'))!=NULL ) *p=' ';
	while ( (p=strchr((char*)lpMsgBuf,'\r'))!=NULL ) *p=' ';
    sprintf(szBuf, "%s (error code %d)", lpMsgBuf, dw); 
 
    LocalFree(lpMsgBuf);
	wunlock(&lock);
	return szBuf;
}
开发者ID:AMFIRNAS,项目名称:wso2-gridlabd,代码行数:26,代码来源:validate.cpp

示例14: fs_chaninit

/*
 * allocate 'count' contiguous channels
 * of type 'type' and return pointer to base
 */
Chan*
fs_chaninit(int type, int count, int data)
{
	uint8_t *p;
	Chan *cp, *icp;
	int i;

	p = malloc(count * (sizeof(Chan)+data));
	icp = (Chan*)p;
	for(i = 0; i < count; i++) {
		cp = (Chan*)p;
		cp->next = chans;
		chans = cp;
		cp->type = type;
		cp->chan = cons.chano;
		cons.chano++;
		strncpy(cp->whoname, "<none>", sizeof cp->whoname);
		wlock(&cp->reflock);
		wunlock(&cp->reflock);
		rlock(&cp->reflock);
		runlock(&cp->reflock);

		p += sizeof(Chan);
		if(data){
			cp->pdata = p;
			p += data;
		}
	}
	return icp;
}
开发者ID:npe9,项目名称:harvey,代码行数:34,代码来源:sub.c

示例15: envremove

static void
envremove(Chan *c)
{
	int i;
	Egrp *eg;
	Evalue *e;

	if(c->qid.type & QTDIR)
		error(Eperm);

	eg = envgrp(c);
	wlock(&eg->rwl);
	e = 0;
	for(i=0; i<eg->nent; i++){
		if(eg->ent[i]->qid.path == c->qid.path){
			e = eg->ent[i];
			eg->nent--;
			eg->ent[i] = eg->ent[eg->nent];
			eg->vers++;
			break;
		}
	}
	wunlock(&eg->rwl);
	if(e == 0)
		error(Enonexist);
	free(e->name);
	if(e->value)
		free(e->value);
	free(e);
}
开发者ID:Requaos,项目名称:harvey,代码行数:30,代码来源:devenv.c


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