本文整理汇总了C++中ReleaseReadLock函数的典型用法代码示例。如果您正苦于以下问题:C++ ReleaseReadLock函数的具体用法?C++ ReleaseReadLock怎么用?C++ ReleaseReadLock使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReleaseReadLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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;
}
示例3: 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;
}
示例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;
}
示例5: 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;
}
示例6: ObtainReadLock
bool bbuf::empty(void)
{
ObtainReadLock(&lock);
if (count == 0) {
ReleaseReadLock(&lock);
return mtrue;
} else {
ReleaseReadLock(&lock);
return mfalse;
}
}
示例7: 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;
}
示例8: afs_FindDCacheByFid
/*!
* Find the first dcache of a file that has the specified fid.
* Similar to afs_FindDCache, only that it takes a fid instead
* of a vcache and it can get the first dcache.
*
* \param afid
*
* \return The found dcache or NULL.
*/
struct dcache *
afs_FindDCacheByFid(struct VenusFid *afid)
{
afs_int32 i, index;
struct dcache *tdc = NULL;
i = DVHash(afid);
ObtainWriteLock(&afs_xdcache, 758);
for (index = afs_dvhashTbl[i]; index != NULLIDX;) {
if (afs_indexUnique[index] == afid->Fid.Unique) {
tdc = afs_GetValidDSlot(index);
if (tdc) {
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, afid)) {
break; /* leaving refCount high for caller */
}
afs_PutDCache(tdc);
}
}
index = afs_dvnextTbl[index];
}
ReleaseWriteLock(&afs_xdcache);
if (index == NULLIDX)
tdc = NULL;
return tdc;
}
示例9: 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);
}
示例10: 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;
}
}
示例11: ulock_relLock
/*!
* \brief Release the transaction lock.
*/
void
ulock_relLock(struct ubik_trans *atrans)
{
if (atrans->locktype == LOCKWRITE && (atrans->flags & TRREADWRITE)) {
ubik_print("Ubik: Internal Error: unlocking write lock with "
"TRREADWRITE?\n");
abort();
}
if (atrans->flags & TRREADWRITE) {
/* noop, TRREADWRITE means we don't actually lock anything */
} else if (atrans->locktype == LOCKREAD) {
ReleaseReadLock(&rwlock);
} else if (atrans->locktype == LOCKWRITE) {
ReleaseWriteLock(&rwlock);
}
/*
*ubik_print("Ubik: DEBUG: Thread 0x%x %s unlock\n", lwp_cpptr,
* ((atrans->locktype == LOCKREAD) ? "READ" : "WRITE"));
*/
atrans->locktype = 0;
return;
}
示例12: ObtainReadLock
//----------------------------------------------------------------------------------------
unsigned int GenericAccessGroupCollectionEntry::GetEntryCount() const
{
ObtainReadLock();
unsigned int entryCount = (unsigned int)entries.size();
ReleaseReadLock();
return entryCount;
}
示例13: SearchThreadFunc
/*
* Every so often, walked the linked list
* and figure out how many lines one string
* appears (given as the startup param)
*/
DWORD WINAPI SearchThreadFunc(LPVOID n)
{
int i;
char *szSearch = (char *)n;
for (i=0; i<20; i++)
{
int nFoundCount = 0;
Node *next = NULL;
AcquireReadLock(&gpList->lock);
next = Next(gpList, next);
while (next)
{
if (strstr(next->szBuffer, szSearch))
nFoundCount++;
next = Next(gpList, next);
}
ReleaseReadLock(&gpList->lock);
printf("Found %d lines with '%s'\n", nFoundCount, szSearch);
Sleep((rand() % 30));
}
return 0;
}
示例14: exporter_find
/* Returns the "afs exporter" structure of type, "type". NULL is returned if not found */
struct afs_exporter *
exporter_find(int type)
{
struct afs_exporter *op;
AFS_STATCNT(exporter_add);
ObtainReadLock(&afs_xexp);
for (op = root_exported; op; op = op->exp_next) {
if (op->exp_type == type) {
ReleaseReadLock(&afs_xexp);
return op;
}
}
ReleaseReadLock(&afs_xexp);
return (struct afs_exporter *)0;
}
示例15: 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);
}
}