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

C++ ObtainReadLock函数代码示例

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

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



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

示例1: afs_GetDynrootMount

void
afs_GetDynrootMount(char **dynrootDir, int *dynrootLen,
		    struct AFSFetchStatus *status)
{
    ObtainReadLock(&afs_dynrootDirLock);
    if (!afs_dynrootMountDir) {
	ReleaseReadLock(&afs_dynrootDirLock);
	afs_RebuildDynrootMount();
	ObtainReadLock(&afs_dynrootDirLock);
    }

    if (dynrootDir)
	*dynrootDir = afs_dynrootMountDir;
    if (dynrootLen)
	*dynrootLen = afs_dynrootMountDirLen;

    if (status) {
	memset(status, 0, sizeof(struct AFSFetchStatus));
	status->FileType = Directory;
	status->LinkCount = 1;
	status->Length = afs_dynrootMountDirLen;
	status->DataVersion = 1;
	status->CallerAccess = PRSFS_LOOKUP | PRSFS_READ;
	status->AnonymousAccess = PRSFS_LOOKUP | PRSFS_READ;
	status->UnixModeBits = 0755;
	status->ParentVnode = 1;
	status->ParentUnique = 1;
	status->dataVersionHigh = 0;
    }
}
开发者ID:stevenjenkins,项目名称:openafs,代码行数:30,代码来源:afs_dynroot.c


示例2: DFlush

int
DFlush(void)
{
    /* Flush all the modified buffers. */
    int i;
    struct buffer **tbp;
    afs_int32 code, rcode;

    rcode = 0;
    tbp = Buffers;
    ObtainReadLock(&afs_bufferLock);
    for (i = 0; i < nbuffers; i++, tbp++) {
	if ((*tbp)->dirty) {
	    ObtainWriteLock(&(*tbp)->lock);
	    (*tbp)->lockers++;
	    ReleaseReadLock(&afs_bufferLock);
	    if ((*tbp)->dirty) {
		code = ReallyWrite((*tbp)->fid, (*tbp)->page, (*tbp)->data);
		if (!code)
		    (*tbp)->dirty = 0;	/* Clear the dirty flag */
		if (code && !rcode) {
		    rcode = code;
		}
	    }
	    (*tbp)->lockers--;
	    ReleaseWriteLock(&(*tbp)->lock);
	    ObtainReadLock(&afs_bufferLock);
	}
    }
    ReleaseReadLock(&afs_bufferLock);
    return rcode;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:32,代码来源:buffer.c


示例3: DFlushEntry

int
DFlushEntry(afs_int32 *fid)
{
    /* Flush pages modified by one entry. */
    struct buffer *tb;
    int code;

    ObtainReadLock(&afs_bufferLock);
    for (tb = phTable[pHash(fid)]; tb; tb = tb->hashNext)
	if (FidEq(tb->fid, fid) && tb->dirty) {
	    ObtainWriteLock(&tb->lock);
	    if (tb->dirty) {
		code = ReallyWrite(tb->fid, tb->page, tb->data);
		if (code) {
		    ReleaseWriteLock(&tb->lock);
		    ReleaseReadLock(&afs_bufferLock);
		    return code;
		}
		tb->dirty = 0;
	    }
	    ReleaseWriteLock(&tb->lock);
	}
    ReleaseReadLock(&afs_bufferLock);
    return 0;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:25,代码来源:buffer.c


示例4: afs_MemReadBlk

/*
 * this routine simulates a read in the Memory Cache
 */
int
afs_MemReadBlk(struct osi_file *fP, int offset, void *dest,
	       int size)
{
    struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
    int bytesRead;

    ObtainReadLock(&mceP->afs_memLock);
    AFS_STATCNT(afs_MemReadBlk);
    if (offset < 0) {
	ReleaseReadLock(&mceP->afs_memLock);
	return 0;
    }
    /* use min of bytes in buffer or requested size */
    bytesRead = (size < mceP->size - offset) ? size : mceP->size - offset;

    if (bytesRead > 0) {
	AFS_GUNLOCK();
	memcpy(dest, mceP->data + offset, bytesRead);
	AFS_GLOCK();
    } else
	bytesRead = 0;

    ReleaseReadLock(&mceP->afs_memLock);
    return bytesRead;
}
开发者ID:adeason,项目名称:openafs,代码行数:29,代码来源:afs_memcache.c


示例5: afs_GetCellHostsAFSDB

/*!
 * \brief Query the AFSDB handler and wait for response.
 * \param  acellName
 * \return 0 for success. < 0 is error.
 */
static int
afs_GetCellHostsAFSDB(char *acellName)
{
    AFS_ASSERT_GLOCK();
    if (!afsdb_handler_running)
	return ENOENT;

    ObtainWriteLock(&afsdb_client_lock, 685);
    ObtainWriteLock(&afsdb_req_lock, 686);

    afsdb_req.cellname = acellName;

    afsdb_req.complete = 0;
    afsdb_req.pending = 1;
    afs_osi_Wakeup(&afsdb_req);
    ConvertWToRLock(&afsdb_req_lock);

    while (afsdb_handler_running && !afsdb_req.complete) {
	ReleaseReadLock(&afsdb_req_lock);
	afs_osi_Sleep(&afsdb_req);
	ObtainReadLock(&afsdb_req_lock);
    };

    ReleaseReadLock(&afsdb_req_lock);
    ReleaseWriteLock(&afsdb_client_lock);

    if (afsdb_req.cellname) {
	return 0;
    } else
	return ENOENT;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:36,代码来源:afs_cell.c


示例6: ObtainReadLock

//----------------------------------------------------------------------------------------
unsigned int GenericAccessGroupCollectionEntry::GetEntryCount() const
{
	ObtainReadLock();
	unsigned int entryCount = (unsigned int)entries.size();
	ReleaseReadLock();
	return entryCount;
}
开发者ID:roman-murashov,项目名称:exodus,代码行数:8,代码来源:GenericAccessGroupCollectionEntry.cpp


示例7: afs_DynrootInvalidate

/*
 * Invalidate the /afs vnode for dynroot; called when the underlying
 * directory has changed and needs to be re-read.
 */
void
afs_DynrootInvalidate(void)
{
    afs_int32 retry;
    struct vcache *tvc;
    struct VenusFid tfid;

    if (!afs_dynrootEnable)
	return;

    ObtainWriteLock(&afs_dynrootDirLock, 687);
    afs_dynrootVersion++;
    afs_dynrootVersionHigh = osi_Time();
    ReleaseWriteLock(&afs_dynrootDirLock);

    afs_GetDynrootFid(&tfid);
    do {
	retry = 0;
	ObtainReadLock(&afs_xvcache);
	tvc = afs_FindVCache(&tfid, &retry, 0);
	ReleaseReadLock(&afs_xvcache);
    } while (retry);
    if (tvc) {
	tvc->f.states &= ~(CStatd | CUnique);
	osi_dnlc_purgedp(tvc);
	afs_PutVCache(tvc);
    }
}
开发者ID:stevenjenkins,项目名称:openafs,代码行数:32,代码来源:afs_dynroot.c


示例8: afs_DbgDisconFiles

/*!
 * Print list of disconnected files.
 *
 * \note Call with afs_DDirtyVCListLock read locked.
 */
void
afs_DbgDisconFiles(void)
{
    struct vcache *tvc;
    struct afs_q *q;
    int i = 0;

    afs_warn("List of dirty files: \n");

    ObtainReadLock(&afs_disconDirtyLock);
    for (q = QPrev(&afs_disconDirty); q != &afs_disconDirty; q = QPrev(q)) {
        tvc = QEntry(q, struct vcache, dirtyq);

	afs_warn("Cell=%u Volume=%u VNode=%u Unique=%u\n",
		tvc->f.fid.Cell,
		tvc->f.fid.Fid.Volume,
		tvc->f.fid.Fid.Vnode,
		tvc->f.fid.Fid.Unique);

	i++;
	if (i >= 30)
	    osi_Panic("afs_DbgDisconFiles: loop in dirty list\n");
    }
    ReleaseReadLock(&afs_disconDirtyLock);
}
开发者ID:adeason,项目名称:openafs,代码行数:30,代码来源:afs_disconnected.c


示例9: afs_MemReadvBlk

/*
 * this routine simulates a readv in the Memory Cache
 */
int
afs_MemReadvBlk(struct memCacheEntry *mceP, int offset,
		struct iovec *iov, int nio, int size)
{
    int i;
    int bytesRead;
    int bytesToRead;

    ObtainReadLock(&mceP->afs_memLock);
    AFS_STATCNT(afs_MemReadBlk);
    if (offset < 0) {
	ReleaseReadLock(&mceP->afs_memLock);
	return 0;
    }
    /* use min of bytes in buffer or requested size */
    bytesRead = (size < mceP->size - offset) ? size : mceP->size - offset;

    if (bytesRead > 0) {
	for (i = 0, size = bytesRead; i < nio && size > 0; i++) {
	    bytesToRead = (size < iov[i].iov_len) ? size : iov[i].iov_len;
	    AFS_GUNLOCK();
	    memcpy(iov[i].iov_base, mceP->data + offset, bytesToRead);
	    AFS_GLOCK();
	    offset += bytesToRead;
	    size -= bytesToRead;
	}
	bytesRead -= size;
    } else
	bytesRead = 0;

    ReleaseReadLock(&mceP->afs_memLock);
    return bytesRead;
}
开发者ID:adeason,项目名称:openafs,代码行数:36,代码来源:afs_memcache.c


示例10: SRXAFSCB_GetServerPrefs

int
SRXAFSCB_GetServerPrefs(struct rx_call *a_call, afs_int32 a_index,
			afs_int32 * a_srvr_addr, afs_int32 * a_srvr_rank)
{
    int i, j;
    struct srvAddr *sa;

    RX_AFS_GLOCK();
    AFS_STATCNT(SRXAFSCB_GetServerPrefs);

    ObtainReadLock(&afs_xserver);

    /* Search the hash table for the server with this index */
    *a_srvr_addr = 0xffffffff;
    *a_srvr_rank = 0xffffffff;
    for (i = 0, j = 0; j < NSERVERS && i <= a_index; j++) {
	for (sa = afs_srvAddrs[j]; sa && i <= a_index; sa = sa->next_bkt, i++) {
	    if (i == a_index) {
		*a_srvr_addr = ntohl(sa->sa_ip);
		*a_srvr_rank = sa->sa_iprank;
	    }
	}
    }

    ReleaseReadLock(&afs_xserver);

    RX_AFS_GUNLOCK();

    return 0;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:30,代码来源:afs_callback.c


示例11: SRXAFSCB_WhoAreYou

int
SRXAFSCB_WhoAreYou(struct rx_call *a_call, struct interfaceAddr *addr)
{
    int i;
    int code = 0;

    RX_AFS_GLOCK();

    AFS_STATCNT(SRXAFSCB_WhoAreYou);

    memset(addr, 0, sizeof(*addr));

    ObtainReadLock(&afs_xinterface);

    /* return all network interface addresses */
    addr->numberOfInterfaces = afs_cb_interface.numberOfInterfaces;
    addr->uuid = afs_cb_interface.uuid;
    for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) {
	addr->addr_in[i] = ntohl(afs_cb_interface.addr_in[i]);
	addr->subnetmask[i] = ntohl(afs_cb_interface.subnetmask[i]);
	addr->mtu[i] = ntohl(afs_cb_interface.mtu[i]);
    }

    ReleaseReadLock(&afs_xinterface);

    RX_AFS_GUNLOCK();

    return code;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:29,代码来源:afs_callback.c


示例12: afs_UFSHandleLink

int
afs_UFSHandleLink(register struct vcache *avc, struct vrequest *areq)
{
    register struct dcache *tdc;
    register char *tp, *rbuf;
    void *tfile;
    afs_size_t offset, len;
    afs_int32 tlen, alen;
    register afs_int32 code;

    /* two different formats, one for links protected 644, have a "." at the
     * end of the file name, which we turn into a null.  Others, protected
     * 755, we add a null to the end of */
    AFS_STATCNT(afs_UFSHandleLink);
    if (!avc->linkData) {
        tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 0);
        afs_Trace3(afs_iclSetp, CM_TRACE_UFSLINK, ICL_TYPE_POINTER, avc,
                   ICL_TYPE_POINTER, tdc, ICL_TYPE_OFFSET,
                   ICL_HANDLE_OFFSET(avc->f.m.Length));
        if (!tdc) {
            if (AFS_IS_DISCONNECTED)
                return ENETDOWN;
            else
                return EIO;
        }
        /* otherwise we have the data loaded, go for it */
        if (len > 1024) {
            afs_PutDCache(tdc);
            return EFAULT;
        }
        if (avc->f.m.Mode & 0111)
            alen = len + 1;	/* regular link */
        else
            alen = len;		/* mt point */
        rbuf = (char *)osi_AllocLargeSpace(AFS_LRALLOCSIZ);
        tlen = len;
        ObtainReadLock(&tdc->lock);
#if defined(LINUX_USE_FH)
        tfile = osi_UFSOpen_fh(&tdc->f.fh, tdc->f.fh_type);
#else
        tfile = osi_UFSOpen(tdc->f.inode);
#endif
        code = afs_osi_Read(tfile, -1, rbuf, tlen);
        osi_UFSClose(tfile);
        ReleaseReadLock(&tdc->lock);
        afs_PutDCache(tdc);
        rbuf[alen - 1] = '\0';
        alen = strlen(rbuf) + 1;
        tp = afs_osi_Alloc(alen);	/* make room for terminating null */
        memcpy(tp, rbuf, alen);
        osi_FreeLargeSpace(rbuf);
        if (code != tlen) {
            afs_osi_Free(tp, alen);
            return EIO;
        }
        avc->linkData = tp;
    }
    return 0;
}
开发者ID:maxendpoint,项目名称:openafs_cvs,代码行数:59,代码来源:afs_vnop_symlink.c


示例13: ulock_getLock

/*!
 * \brief Set a transaction lock.
 * \param atype is #LOCKREAD or #LOCKWRITE.
 * \param await is TRUE if you want to wait for the lock instead of returning
 * #EWOULDBLOCK.
 *
 * \note The #DBHOLD lock must be held.
 */
extern int
ulock_getLock(struct ubik_trans *atrans, int atype, int await)
{
    struct ubik_dbase *dbase = atrans->dbase;

    if ((atype != LOCKREAD) && (atype != LOCKWRITE))
	return EINVAL;

    if (atrans->flags & TRDONE)
	return UDONE;

    if (atype != LOCKREAD && (atrans->flags & TRREADWRITE)) {
	return EINVAL;
    }

    if (atrans->locktype != 0) {
	ubik_print("Ubik: Internal Error: attempted to take lock twice\n");
	abort();
    }

/*
 *ubik_print("Ubik: DEBUG: Thread 0x%x request %s lock\n", lwp_cpptr,
 *	     ((atype == LOCKREAD) ? "READ" : "WRITE"));
 */

    /* Check if the lock would would block */
    if (!await && !(atrans->flags & TRREADWRITE)) {
	if (atype == LOCKREAD) {
	    if (WouldReadBlock(&rwlock))
		return EAGAIN;
	} else {
	    if (WouldWriteBlock(&rwlock))
		return EAGAIN;
	}
    }

    /* Create new lock record and add to spec'd transaction:
     * locktype. This field also tells us if the thread is
     * waiting for a lock: It will be equal to LOCKWAIT.
     */
    atrans->locktype = LOCKWAIT;
    DBRELE(dbase);
    if (atrans->flags & TRREADWRITE) {
	/* noop; don't actually lock anything for TRREADWRITE */
    } else if (atype == LOCKREAD) {
	ObtainReadLock(&rwlock);
    } else {
	ObtainWriteLock(&rwlock);
    }
    DBHOLD(dbase);
    atrans->locktype = atype;

/*
 *ubik_print("Ubik: DEBUG: Thread 0x%x took %s lock\n", lwp_cpptr,
 *	     ((atype == LOCKREAD) ? "READ" : "WRITE"));
 */
    return 0;
}
开发者ID:bagdxk,项目名称:openafs,代码行数:66,代码来源:lock.c


示例14: afs_CellOrAliasExists

/*!
 * Check if the given name exists as a cell or alias. Locks afs_xcell.
 * \param aname
 * \return
 */
int
afs_CellOrAliasExists(char *aname)
{
    int ret;

    ObtainReadLock(&afs_xcell);
    ret = afs_CellOrAliasExists_nl(aname);
    ReleaseReadLock(&afs_xcell);

    return ret;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:16,代码来源:afs_cell.c


示例15: afs_TraverseCells

/*!
 * Execute a callback for each existing cell, with a lock on afs_xcell.
 * \see afs_TraverseCells_nl
 * \param cb Traversal callback for each cell.
 * \param arg
 * \return Found data or NULL.
 */
void *
afs_TraverseCells(void *(*cb) (struct cell *, void *), void *arg)
{
    void *ret;

    ObtainReadLock(&afs_xcell);
    ret = afs_TraverseCells_nl(cb, arg);
    ReleaseReadLock(&afs_xcell);

    return ret;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:18,代码来源:afs_cell.c


示例16: ObtainReadLock

bool bbuf::full(void)
{
    ObtainReadLock(&lock);
    if (count == bnd) {
        ReleaseReadLock(&lock);
        return mtrue;
    } else {
        ReleaseReadLock(&lock);
        return mfalse;
    }
}
开发者ID:cmusatyalab,项目名称:coda,代码行数:11,代码来源:bbuf.c


示例17: afs_GetCellAlias

/*!
 * Get cell alias by index (starting at 0).
 * \param index Cell index.
 * \return Found struct or null.
 */
struct cell_alias *
afs_GetCellAlias(int index)
{
    struct cell_alias *tc;

    ObtainReadLock(&afs_xcell);
    for (tc = afs_cellalias_head; tc != NULL; tc = tc->next)
	if (tc->index == index)
	    break;
    ReleaseReadLock(&afs_xcell);

    return tc;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:18,代码来源:afs_cell.c


示例18: DFlush

int
DFlush(void)
{
    /* Flush all the modified buffers. */
    int i;
    struct buffer *tb;

    AFS_STATCNT(DFlush);
    tb = Buffers;
    ObtainReadLock(&afs_bufferLock);
    for (i = 0; i < nbuffers; i++, tb++) {
	if (tb->dirty) {
	    ObtainWriteLock(&tb->lock, 263);
	    tb->lockers++;
	    ReleaseReadLock(&afs_bufferLock);
	    if (tb->dirty) {
		/* it seems safe to do this I/O without having the dcache
		 * locked, since the only things that will update the data in
		 * a directory are the buffer package, which holds the relevant
		 * tb->lock while doing the write, or afs_GetDCache, which
		 * DZap's the directory while holding the dcache lock.
		 * It is not possible to lock the dcache or even call
		 * afs_GetDSlot to map the index to the dcache since the dir
		 * package's caller has some dcache object locked already (so
		 * we cannot lock afs_xdcache). In addition, we cannot obtain
		 * a dcache lock while holding the tb->lock of the same file
		 * since that can deadlock with DRead/DNew */
		DFlushBuffer(tb);
	    }
	    tb->lockers--;
	    ReleaseWriteLock(&tb->lock);
	    ObtainReadLock(&afs_bufferLock);
	}
    }
    ReleaseReadLock(&afs_bufferLock);

    return 0;
}
开发者ID:jisqyv,项目名称:openafs,代码行数:38,代码来源:afs_buffer.c


示例19: DZap

void
DZap(dir_file_t dir)
{
    /* Destroy all buffers pertaining to a particular fid. */
    struct buffer *tb;
    ObtainReadLock(&afs_bufferLock);
    for (tb = phTable[pHash(dir)]; tb; tb = tb->hashNext)
	if (FidEq(bufferDir(tb), dir)) {
	    ObtainWriteLock(&tb->lock);
	    FidZap(bufferDir(tb));
	    tb->dirty = 0;
	    ReleaseWriteLock(&tb->lock);
	}
    ReleaseReadLock(&afs_bufferLock);
}
开发者ID:bagdxk,项目名称:openafs,代码行数:15,代码来源:buffer.c


示例20: DZap

void
DZap(afs_int32 *fid)
{
    /* Destroy all buffers pertaining to a particular fid. */
    struct buffer *tb;
    ObtainReadLock(&afs_bufferLock);
    for (tb = phTable[pHash(fid)]; tb; tb = tb->hashNext)
	if (FidEq(tb->fid, fid)) {
	    ObtainWriteLock(&tb->lock);
	    FidZap(tb->fid);
	    tb->dirty = 0;
	    ReleaseWriteLock(&tb->lock);
	}
    ReleaseReadLock(&afs_bufferLock);
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:15,代码来源:buffer.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ObtainSemaphore函数代码示例发布时间:2022-05-30
下一篇:
C++ ObjectiveResource函数代码示例发布时间: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