當前位置: 首頁>>代碼示例>>C++>>正文


C++ AcquireSRWLockExclusive函數代碼示例

本文整理匯總了C++中AcquireSRWLockExclusive函數的典型用法代碼示例。如果您正苦於以下問題:C++ AcquireSRWLockExclusive函數的具體用法?C++ AcquireSRWLockExclusive怎麽用?C++ AcquireSRWLockExclusive使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AcquireSRWLockExclusive函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: AcquireSRWLockExclusive

BOOL CRWLockSlim::AcquireWriterLock( DWORD dwTimeout )
{
    BOOL bRet = FALSE;

#if ( _WIN32_WINNT_WIN7 <= _WIN32_WINNT )
    if ( INFINITE == dwTimeout || FALSE == m_bWin7AndLater )
    {
        AcquireSRWLockExclusive( &m_srwLock );
        bRet = TRUE;
    }
    else
    {
        LARGE_INTEGER lnCurr , lnEnd;
        QueryPerformanceCounter( &lnCurr );
        lnEnd.QuadPart = lnCurr.QuadPart + dwTimeout * ( m_lnFreq.QuadPart / 1000 );
        do
        {
            QueryPerformanceCounter( &lnCurr );
            bRet = (BOOL)TryAcquireSRWLockExclusive( &m_srwLock );
        } while ( lnCurr.QuadPart < lnEnd.QuadPart );
    }
#else
    AcquireSRWLockExclusive( &m_srwLock );
    bRet = TRUE;
#endif

    return bRet;
}
開發者ID:winest,項目名稱:CWUtils,代碼行數:28,代碼來源:CWLock.cpp

示例2: TRI_LockMutex

void TRI_LockMutex (TRI_mutex_t* mutex) {
  // as of VS2013, exclusive SRWLocks tend to be faster than native mutexes
#if TRI_WINDOWS_VISTA_LOCKS
  DWORD result = WaitForSingleObject(mutex->_mutex, INFINITE);

  switch (result) {
    case WAIT_ABANDONED: {
      LOG_FATAL_AND_EXIT("locks-win32.c:TRI_LockMutex:could not lock the condition --> WAIT_ABANDONED");
    }

    case WAIT_OBJECT_0: {
      // everything ok
      break;
    }

    case WAIT_TIMEOUT: {
      LOG_FATAL_AND_EXIT("locks-win32.c:TRI_LockMutex:could not lock the condition --> WAIT_TIMEOUT");
    }

    case WAIT_FAILED: {
      result = GetLastError();
      LOG_FATAL_AND_EXIT("locks-win32.c:TRI_LockMutex:could not lock the condition --> WAIT_FAILED - reason -->%d",result);
    }
  }
#else
  AcquireSRWLockExclusive(&mutex->_mutex);
#endif
}
開發者ID:CoDEmanX,項目名稱:ArangoDB,代碼行數:28,代碼來源:locks-win32.cpp

示例3: cache_insert

static int cache_insert(
    struct idmap_cache *cache,
    const struct idmap_lookup *lookup,
    const struct list_entry *src)
{
    struct list_entry *entry;
    int status = NO_ERROR;

    AcquireSRWLockExclusive(&cache->lock);

    /* search for an existing match */
    entry = list_search(&cache->head, lookup->value, lookup->compare);
    if (entry) {
        /* overwrite the existing entry with the new results */
        cache->ops->entry_copy(entry, src);
        goto out;
    }

    /* initialize a new entry and add it to the list */
    entry = cache->ops->entry_alloc();
    if (entry == NULL) {
        status = GetLastError();
        goto out;
    }
    cache->ops->entry_copy(entry, src);
    list_add_head(&cache->head, entry);
out:
    ReleaseSRWLockExclusive(&cache->lock);
    return status;
}
開發者ID:AchillesA,項目名稱:ms-nfs41-client,代碼行數:30,代碼來源:idmap.c

示例4: __MCF_CRT_TlsThreadCleanup

void __MCF_CRT_TlsThreadCleanup(){
	ThreadMap *const pMap = TlsGetValue(g_dwTlsIndex);
	if(pMap){
		TlsObject *pObject = pMap->pLastByThread;
		while(pObject){
			TlsKey *const pKey = pObject->pKey;

			AcquireSRWLockExclusive(&(pKey->srwLock));
			{
				if(pKey->pLastByKey == pObject){
					pKey->pLastByKey = pObject->pPrevByKey;
				}
			}
			ReleaseSRWLockExclusive(&(pKey->srwLock));

			if(pKey->pfnCallback){
				(*pKey->pfnCallback)(pObject->nValue);
			}

			TlsObject *const pTemp = pObject->pPrevByThread;
			free(pObject);
			pObject = pTemp;
		}
		free(pMap);
		TlsSetValue(g_dwTlsIndex, nullptr);
	}

	__MCF_CRT_RunEmutlsDtors();
}
開發者ID:Gd58,項目名稱:MCF,代碼行數:29,代碼來源:thread.c

示例5: AcquireSRWLockExclusive

				_EXP_IMPL void __cdecl Event::set()
				{
					AcquireSRWLockExclusive(reinterpret_cast<PSRWLOCK>(&m_lock));
					m_isSet = true;
					WakeAllConditionVariable(reinterpret_cast<PCONDITION_VARIABLE>(&m_cond));
					ReleaseSRWLockExclusive(reinterpret_cast<PSRWLOCK>(&m_lock));
				}
開發者ID:kusl,項目名稱:parallelstl,代碼行數:7,代碼來源:event.cpp

示例6: virtualfs_text_llseek

static int virtualfs_text_llseek(struct file *f, loff_t offset, loff_t *newoffset, int whence)
{
	AcquireSRWLockExclusive(&f->rw_lock);
	struct virtualfs_text *file = (struct virtualfs_text *)f;
	loff_t target;
	int r;
	switch (whence)
	{
	case SEEK_SET: target = offset; break;
	case SEEK_CUR: target = file->position + offset; break;
	case SEEK_END: target = file->textlen - offset; break;
	default: r = -L_EINVAL; goto out;
	}
	if (target >= 0 && target < file->textlen)
	{
		file->position = (int)target;
		*newoffset = target;
		r = 0;
	}
	else
		r = -L_EINVAL;
out:
	ReleaseSRWLockExclusive(&f->rw_lock);
	return r;
}
開發者ID:AnXi-TieGuanYin-Tea,項目名稱:flinux,代碼行數:25,代碼來源:virtual.c

示例7: AcquireSRWLockExclusive

BOOST_LOG_API bool once_block_sentry::enter_once_block() const
{
    AcquireSRWLockExclusive(&g_OnceBlockMutex);

    once_block_flag volatile& flag = m_Flag;
    while (flag.status != once_block_flag::initialized)
    {
        if (flag.status == once_block_flag::uninitialized)
        {
            flag.status = once_block_flag::being_initialized;
            ReleaseSRWLockExclusive(&g_OnceBlockMutex);

            // Invoke the initializer block
            return false;
        }
        else
        {
            while (flag.status == once_block_flag::being_initialized)
            {
                BOOST_VERIFY(SleepConditionVariableSRW(
                    &g_OnceBlockCond, &g_OnceBlockMutex, INFINITE, 0));
            }
        }
    }

    ReleaseSRWLockExclusive(&g_OnceBlockMutex);

    return true;
}
開發者ID:Fabiz,項目名稱:log,代碼行數:29,代碼來源:once_block.cpp

示例8: AcquireSRWLockExclusive

VOID
APPLICATION_INFO::ShutDownApplication()
{
    APPLICATION* pApplication = NULL;
    BOOL         fLockAcquired = FALSE;

    // pApplication can be NULL due to app_offline
    if (m_pApplication != NULL)
    {
        AcquireSRWLockExclusive(&m_srwLock);
        fLockAcquired = TRUE;
        if (m_pApplication != NULL)
        {
            pApplication = m_pApplication;

            // Set m_pApplication to NULL first to prevent anyone from using it
            m_pApplication = NULL;
            pApplication->ShutDown();
            pApplication->DereferenceApplication();
        }

        if (fLockAcquired)
        {
            ReleaseSRWLockExclusive(&m_srwLock);
        }
    }
}
開發者ID:akrisiun,項目名稱:IISIntegration,代碼行數:27,代碼來源:applicationinfo.cpp

示例9: server_addrs_add

static void server_addrs_add(
    IN OUT struct server_addrs *addrs,
    IN const netaddr4 *addr)
{
    /* we keep a list of addrs used to connect to each server. once it gets
     * bigger than NFS41_ADDRS_PER_SERVER, overwrite the oldest addrs. use
     * server_addrs.next_index to implement a circular array */

    AcquireSRWLockExclusive(&addrs->lock);

    if (multi_addr_find(&addrs->addrs, addr, NULL)) {
        dprintf(SRVLVL, "server_addrs_add() found existing addr '%s'.\n",
            addr->uaddr);
    } else {
        /* overwrite the address at 'next_index' */
        StringCchCopyA(addrs->addrs.arr[addrs->next_index].netid,
            NFS41_NETWORK_ID_LEN+1, addr->netid);
        StringCchCopyA(addrs->addrs.arr[addrs->next_index].uaddr,
            NFS41_UNIVERSAL_ADDR_LEN+1, addr->uaddr);

        /* increment/wrap next_index */
        addrs->next_index = (addrs->next_index + 1) % NFS41_ADDRS_PER_SERVER;
        /* update addrs.count if necessary */
        if (addrs->addrs.count < addrs->next_index)
            addrs->addrs.count = addrs->next_index;

        dprintf(SRVLVL, "server_addrs_add() added new addr '%s'.\n",
            addr->uaddr);
    }
    ReleaseSRWLockExclusive(&addrs->lock);
}
開發者ID:AchillesA,項目名稱:ms-nfs41-client,代碼行數:31,代碼來源:nfs41_server.c

示例10: open_unlock_delegate

static int open_unlock_delegate(
    IN nfs41_open_state *open,
    IN const nfs41_lock_state *input)
{
    struct list_entry *entry;
    int status = ERROR_NOT_LOCKED;

    AcquireSRWLockExclusive(&open->lock);

    /* find lock state that matches this range */
    entry = list_search(&open->locks.list, input, lock_range_cmp);
    if (entry) {
        nfs41_lock_state *lock = lock_entry(entry);
        if (lock->delegated) {
            /* if the lock was delegated, remove/free it and return success */
            list_remove(entry);
            free(lock);
            status = NO_ERROR;
        } else
            status = ERROR_LOCKED;
    }

    ReleaseSRWLockExclusive(&open->lock);
    return status;
}
開發者ID:AchillesA,項目名稱:ms-nfs41-client,代碼行數:25,代碼來源:lock.c

示例11: belle_sip_mutex_lock

int belle_sip_mutex_lock(belle_sip_mutex_t * hMutex) {
#ifdef BELLE_SIP_WINDOWS_DESKTOP
	WaitForSingleObject(*hMutex, INFINITE);
#else
	AcquireSRWLockExclusive(hMutex);
#endif
	return 0;
}
開發者ID:Distrotech,項目名稱:belle-sip,代碼行數:8,代碼來源:port.c

示例12: AcquireSRWLockExclusive

/// <summary>
/// Locks for writing.
/// </summary>
void RWLock::LockWrite()
{
#ifdef PLATFORM_WIN
	AcquireSRWLockExclusive( &mRwlock );
#else
	pthread_rwlock_wrlock( &mRwlock );
#endif
}
開發者ID:Inch4Tk,項目名稱:ModernDB2016SS,代碼行數:11,代碼來源:RWLock.cpp

示例13: mutex_lock

int mutex_lock(struct mutex_handle *mutex)
{
	struct mutex_priv *priv = (struct mutex_priv *)mutex->priv;

	AcquireSRWLockExclusive(&priv->lock);

	return 0;
}
開發者ID:cottsay,項目名稱:openelp,代碼行數:8,代碼來源:mutex_win.c

示例14: MCF_CRT_TlsFreeKey

bool MCF_CRT_TlsFreeKey(void *pTlsKey){
	TlsKey *const pKey = pTlsKey;
	if(!pKey){
		SetLastError(ERROR_INVALID_PARAMETER);
		return false;
	}

	AcquireSRWLockExclusive(&g_csKeyMutex);
	{
		MCF_AvlDetach((MCF_AvlNodeHeader *)pKey);
	}
	ReleaseSRWLockExclusive(&g_csKeyMutex);

	TlsObject *pObject = pKey->pLastByKey;
	while(pObject){
		ThreadMap *const pMap = pObject->pMap;

		AcquireSRWLockExclusive(&(pMap->srwLock));
		{
			TlsObject *const pPrev = pObject->pPrevByThread;
			TlsObject *const pNext = pObject->pNextByThread;
			if(pPrev){
				pPrev->pNextByThread = pNext;
			}
			if(pNext){
				pNext->pPrevByThread = pPrev;
			}

			if(pMap->pLastByThread == pObject){
				pMap->pLastByThread = pObject->pPrevByThread;
			}
		}
		ReleaseSRWLockExclusive(&(pMap->srwLock));

		if(pKey->pfnCallback){
			(*pKey->pfnCallback)(pObject->nValue);
		}

		TlsObject *const pTemp = pObject->pPrevByKey;
		free(pObject);
		pObject = pTemp;
	}
	free(pKey);

	return true;
}
開發者ID:Gd58,項目名稱:MCF,代碼行數:46,代碼來源:thread.c

示例15: GetCurrentThreadId

 // the code below in _DEBUG build will check that we don't try to recursively lock, 
 // which is not supported by this class.  also checks that you don't unlock without 
 // having locked
 void SimpleRWLock::lock() {
     unsigned me = GetCurrentThreadId();
     int& state = s.getRef();
     dassert( state == 0 );
     state--;
     AcquireSRWLockExclusive(&_lock);
     tid = me; // this is for use in the debugger to see who does have the lock
 }
開發者ID:2812140729,項目名稱:robomongo,代碼行數:11,代碼來源:rwlockimpl.cpp


注:本文中的AcquireSRWLockExclusive函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。