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

C++ sLock函数代码示例

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

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



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

示例1: sLock

BOOL CTcpSocket::Write(char * pData, int iLength)
{
	if (m_hOutputEvent == NULL)	return FALSE;

	CSingleLock sLock(&m_critical);
	WSABUF * p = (WSABUF *)malloc(sizeof(WSABUF));
	if (p == NULL)
	{
		OutputDebugString(_T("malloc failed in CTcpSocket::Write\n"));
		return FALSE;
	}
	p->buf = (char *)malloc(TCP_BUFFER_LENGTH);
	if (p->buf == NULL)
	{
		free(p);
		OutputDebugString(_T("malloc failed in CTcpSocket::Write\n"));
		return FALSE;
	}
	memcpy(p->buf, pData, iLength);
	p->len = iLength;
	sLock.Lock();
	m_sendQueue.AddTail(p);
	sLock.Unlock();
	SetEvent(m_hOutputEvent);
//	Sleep(0);
	return TRUE;
}
开发者ID:AlexVangelov,项目名称:ar168l,代码行数:27,代码来源:TcpSocket.cpp


示例2: sLock

///////////////////////////////////////////////////////////////////////////
// CTSPIConferenceCall::RemoveConferenceCall
//
// Remove the conference call specified from our array.  Callstate
// of the removed call is not changed.  Conference is idle'd if this
// is the last call.
//
void CTSPIConferenceCall::RemoveConferenceCall(CTSPICallAppearance* pCall, bool fForceBreakdown /*=true*/)
{   
    // Locate the call appearance and remove it.
	CEnterCode sLock(this);  // Synch access to object
	TCallHubList::iterator pos = std::find(m_lstConference.begin(), m_lstConference.end(), pCall);
	if (pos != m_lstConference.end())
	{
		m_lstConference.erase(pos);
		pCall->SetConferenceOwner(NULL);
		
		// If we have no more calls in our array, then transition 
		// the conference to IDLE.
		if (m_lstConference.empty() && fForceBreakdown)
			SetCallState(LINECALLSTATE_IDLE);

		// Otherwise if we have a single party and we are supposed to breakdown
		// the conference to a two-party call, then do so now.
		else if (m_lstConference.size() == 1 && fForceBreakdown)
		{
			pCall = GetConferenceCall(0);
			RemoveConferenceCall(pCall);
			if (pCall->GetCallState() == LINECALLSTATE_CONFERENCED)
			{
				// If the remove state is not IDLE, change the call state to the given
				// state in the ADDRESSCAPS structure.
				if (GetAddressOwner()->GetAddressCaps()->dwRemoveFromConfState != LINECALLSTATE_IDLE)
					pCall->SetCallState(GetAddressOwner()->GetAddressCaps()->dwRemoveFromConfState);
				else
					pCall->SetCallState(LINECALLSTATE_CONNECTED);
			}
		}
    }               

}// CTSPIConferenceCall::RemoveConferenceCall
开发者ID:junction,项目名称:jn-tapi,代码行数:41,代码来源:Confcall.cpp


示例3: va_start

VOID CLogFile::CacheLog(enum_LOG_LEVEL	logLevel, const CHAR* pLogString , ... )
{
    //等级太低,不需打印控制台和文件
    if (logLevel < m_eConsoleLogLevel && logLevel < m_eFileLogLevel)
    {
        return ;
    }

    CHAR szLine[MAX_LOG_LINE] = {0};
    va_list	va;
    va_start(va,pLogString);
#ifdef __LINUX
    vsprintf(szLine,pLogString,va);
#else
    vsprintf_s(szLine,MAX_LOG_LINE,pLogString,va);
#endif
    va_end(va);

    DateTime now;
    CHAR szLogStr[MAX_LOG_LINE] = {'\0'};
    _snprintf(szLogStr, MAX_LOG_LINE-1, "%2d/%02d/%02d %02d:%02d:%02d.%03d	tId:%ld	%s\n",
              now.GetYear(),
              now.GetMonth(),
              now.GetDay(),
              now.GetHour(),
              now.GetMinute(),
              now.GetSecond(),
              now.GetMilliSecond(),
              GetThreadID(),
              szLine);
    //高等与控制台等级,则打印到控制台
    if (logLevel >= m_eConsoleLogLevel)
    {
        printf("%s", szLogStr);
    }

    //高等与文件等级,则打印到文件
    if (logLevel >= m_eFileLogLevel)
    {
        CSmartLock sLock(m_lock);

        int strLength = strlen(szLogStr);
        if (m_pWriteBuf + strLength - m_pFrontBuf >=  LOG_BUF_LEN)
        {
            //front 缓冲满了
            if (m_bBackBufAvailable)
            {
                //两块全满了,这条要丢。
                printf("LOG LOST!!, %s", szLogStr);
                return;
            }
            //back空着,将front交换到back
            SwitchBuf();
        }

        //写入front
        strcpy( m_pWriteBuf, szLogStr );
        m_pWriteBuf += strLength;
    }
}
开发者ID:soho2515,项目名称:AsynRedisOperate,代码行数:60,代码来源:LogFile.cpp


示例4: sLock

void CBuffer::Empty()
{
	CSingleLock sLock(&m_mutex);
	sLock.Lock();
	m_strBuf.Empty();
	sLock.Unlock();
}
开发者ID:xushiwei,项目名称:pure-lang,代码行数:7,代码来源:Buffer.cpp


示例5: sLock

void MockRemoteDBServer::checkIfUp(InstanceID id) const {
    scoped_spinlock sLock(_lock);

    if (!_isRunning || id < _instanceID) {
        throw mongo::SocketException(mongo::SocketException::CLOSED, _hostAndPort);
    }
}
开发者ID:Andiry,项目名称:mongo,代码行数:7,代码来源:mock_remote_db_server.cpp


示例6: checkIfUp

mongo::BSONArray MockRemoteDBServer::query(MockRemoteDBServer::InstanceID id,
                                           const string& ns,
                                           mongo::Query query,
                                           int nToReturn,
                                           int nToSkip,
                                           const BSONObj* fieldsToReturn,
                                           int queryOptions,
                                           int batchSize) {
    checkIfUp(id);

    if (_delayMilliSec > 0) {
        mongo::sleepmillis(_delayMilliSec);
    }

    checkIfUp(id);

    scoped_spinlock sLock(_lock);
    _queryCount++;

    const vector<BSONObj>& coll = _dataMgr[ns];
    BSONArrayBuilder result;
    for (vector<BSONObj>::const_iterator iter = coll.begin(); iter != coll.end(); ++iter) {
        result.append(iter->copy());
    }

    return BSONArray(result.obj());
}
开发者ID:Andiry,项目名称:mongo,代码行数:27,代码来源:mock_remote_db_server.cpp


示例7: sLock

CKnownFile* CKnownFileList::FindKnownFile(
	const CPath& filename,
	time_t in_date,
	uint64 in_size)
{
	wxMutexLocker sLock(list_mut);

	if (m_knownSizeMap) {
		std::pair<KnownFileSizeMap::const_iterator, KnownFileSizeMap::const_iterator> p;
		p = m_knownSizeMap->equal_range((uint32) in_size);
		for (KnownFileSizeMap::const_iterator it = p.first; it != p.second; ++it) {
			CKnownFile *cur_file = it->second;
			if (KnownFileMatches(cur_file, filename, in_date, in_size)) {
				return cur_file;
			}
		}
	} else {
		for (CKnownFileMap::const_iterator it = m_knownFileMap.begin();
			 it != m_knownFileMap.end(); ++it) {
			CKnownFile *cur_file = it->second;
			if (KnownFileMatches(cur_file, filename, in_date, in_size)) {
				return cur_file;
			}
		}
	}

	return IsOnDuplicates(filename, in_date, in_size);
}
开发者ID:tmphuang6,项目名称:amule,代码行数:28,代码来源:KnownFileList.cpp


示例8: checkIfUp

    bool MockRemoteDBServer::runCommand(MockRemoteDBServer::InstanceID id,
            const string& dbname,
            const BSONObj& cmdObj,
            BSONObj &info,
            int options) {
        checkIfUp(id);

        // Get the name of the command - copied from _runCommands @ db/dbcommands.cpp
        BSONObj innerCmdObj;
        {
            mongo::BSONElement e = cmdObj.firstElement();
            if (e.type() == mongo::Object && (e.fieldName()[0] == '$'
                    ? mongo::str::equals("query", e.fieldName()+1) :
                            mongo::str::equals("query", e.fieldName()))) {
                innerCmdObj = e.embeddedObject();
            }
            else {
                innerCmdObj = cmdObj;
            }
        }

        string cmdName = innerCmdObj.firstElement().fieldName();
        uassert(16430, str::stream() << "no reply for cmd: " << cmdName,
                _cmdMap.count(cmdName) == 1);

        {
            scoped_spinlock sLock(_lock);
            info = _cmdMap[cmdName]->next();
        }

        if (_delayMilliSec > 0) {
            mongo::sleepmillis(_delayMilliSec);
        }

        checkIfUp(id);

        scoped_spinlock sLock(_lock);
        _cmdCount++;
        return info["ok"].trueValue();
    }
开发者ID:10genReviews,项目名称:mongo,代码行数:40,代码来源:mock_remote_db_server.cpp


示例9: getDroidObject

void DroidMaintenanceModuleDataComponent::payStructures(CreatureObject* player, VectorMap<unsigned long long, int> assignments) {
	// we know each struct to pay and any fees applied.
	ManagedReference<DroidObject*> droid = getDroidObject();

	for(int i=0;i< assignments.size();i++) {
		uint64 objectID = assignments.elementAt(i).getKey();
		int maintToPay = assignments.elementAt(i).getValue();
		ManagedReference<SceneObject*> obj = player->getZoneServer()->getObject(objectID);
		StructureObject* structureObject = cast<StructureObject*>(obj.get());
		if (structureObject != NULL)
			Locker sLock(obj,player);
			structureObject->payMaintenance(maintToPay,player,true);
	}
}
开发者ID:blacknightownzjoo,项目名称:SWGOOW,代码行数:14,代码来源:DroidMaintenanceModuleDataComponent.cpp


示例10: dLock

void InStream::routeUpdateHook() {
	AutoMutex dLock(mDev.mLock);
	AutoMutex sLock(mLock);
	int newDevices = -1;
	mParameters.get(AUDIO_PARAMETER_STREAM_ROUTING, newDevices);
	if (mDevices != newDevices && newDevices != -1) {
		ALOGD("Devices changed from 0x%08x to 0x%08x", mDevices, newDevices);
		mDevices = (audio_devices_t) newDevices;
		mDbgStr.clear();
		deviceUpdatePrepare();
		deviceUpdateFinish();
	}
	else
		ALOGE("Bogus device update 0x%08x", newDevices);
}
开发者ID:jsarha,项目名称:ucmhal,代码行数:15,代码来源:UcmHalInStream.cpp


示例11: CPath

bool CKnownFileList::Init()
{
	CFile file;

	CPath fullpath = CPath(theApp->ConfigDir + m_filename);
	if (!fullpath.FileExists()) {
		// This is perfectly normal. The file was probably either
		// deleted, or this is the first time running aMule.
		return false;
	}

	if (!file.Open(fullpath)) {
		AddLogLineC(CFormat(_("WARNING: %s cannot be opened.")) % m_filename);
		return false;
	}

	try {
		uint8 version = file.ReadUInt8();
		if ((version != MET_HEADER) && (version != MET_HEADER_WITH_LARGEFILES)) {
			AddLogLineC(_("WARNING: Known file list corrupted, contains invalid header."));
			return false;
		}

		wxMutexLocker sLock(list_mut);
		uint32 RecordsNumber = file.ReadUInt32();
		AddDebugLogLineN(logKnownFiles, CFormat(wxT("Reading %i known files from file format 0x%2.2x."))
			% RecordsNumber % version);
		for (uint32 i = 0; i < RecordsNumber; i++) {
			CScopedPtr<CKnownFile> record;
			if (record->LoadFromFile(&file)) {
				AddDebugLogLineN(logKnownFiles,
					CFormat(wxT("Known file read: %s")) % record->GetFileName());
				Append(record.release());
			} else {
				AddLogLineC(_("Failed to load entry in known file list, file may be corrupt"));
			}
		}
		AddDebugLogLineN(logKnownFiles, wxT("Finished reading known files"));

		return true;
	} catch (const CInvalidPacket& e) {
		AddLogLineC(_("Invalid entry in known file list, file may be corrupt: ") + e.what());
	} catch (const CSafeIOException& e) {
		AddLogLineC(CFormat(_("IO error while reading %s file: %s")) % m_filename % e.what());
	}

	return false;
}
开发者ID:tmphuang6,项目名称:amule,代码行数:48,代码来源:KnownFileList.cpp


示例12: return

    void Observable::notifyObservers() {
        if (settings_.updatesEnabled()) {
            return (*sig_)();
        }

        boost::lock_guard<boost::mutex> sLock(settings_.mutex_);
        if (settings_.updatesEnabled()) {
            return (*sig_)();
        }
        else if (settings_.updatesDeferred()) {
            boost::lock_guard<boost::recursive_mutex> lock(mutex_);
            // if updates are only deferred, flag this for later notification
            // these are held centrally by the settings singleton
            settings_.registerDeferredObservers(observers_);
        }
    }
开发者ID:aborodya,项目名称:QuantLib-1,代码行数:16,代码来源:observable.cpp


示例13: lock

    void Observable::unregisterObserver(
        const ext::shared_ptr<Observer::Proxy>& observerProxy) {
        {
            boost::lock_guard<boost::recursive_mutex> lock(mutex_);
            observers_.erase(observerProxy);
        }

        if (settings_.updatesDeferred()) {
            boost::lock_guard<boost::mutex> sLock(settings_.mutex_);
            if (settings_.updatesDeferred()) {
                settings_.unregisterDeferredObserver(observerProxy);
            }
        }

        sig_->disconnect(ext::bind(&Observer::Proxy::update,
                             observerProxy.get()));
    }
开发者ID:aborodya,项目名称:QuantLib-1,代码行数:17,代码来源:observable.cpp


示例14: file

void CKnownFileList::Save()
{
	CFile file(theApp->ConfigDir + m_filename, CFile::write_safe);
	if (!file.IsOpened()) {
		return;
	}

	wxMutexLocker sLock(list_mut);
	AddDebugLogLineN(logKnownFiles, CFormat(wxT("start saving %s")) % m_filename);

	try {
		// Kry - This is the version, but we don't know it till
		// we know if any largefile is saved. This allows the list
		// to be compatible with previous versions.
		bool bContainsAnyLargeFiles = false;
		file.WriteUInt8(0);

		file.WriteUInt32(m_knownFileMap.size() + m_duplicateFileList.size());

		// Duplicates handling. Duplicates needs to be saved first,
		// since it is the last entry that gets used.
		KnownFileList::iterator itDup = m_duplicateFileList.begin();
		for ( ; itDup != m_duplicateFileList.end(); ++itDup ) {
			(*itDup)->WriteToFile(&file);
			if ((*itDup)->IsLargeFile()) {
				bContainsAnyLargeFiles = true;
			}
		}

		CKnownFileMap::iterator it = m_knownFileMap.begin();
		for (; it != m_knownFileMap.end(); ++it) {
			it->second->WriteToFile(&file);
			if (it->second->IsLargeFile()) {
				bContainsAnyLargeFiles = true;
			}
		}

		file.Seek(0);
		file.WriteUInt8(bContainsAnyLargeFiles ? MET_HEADER_WITH_LARGEFILES : MET_HEADER);
		file.Close();
	} catch (const CIOFailureException& e) {
		AddLogLineC(CFormat(_("Error while saving %s file: %s")) % m_filename % e.what());
	}
	AddDebugLogLineN(logKnownFiles, CFormat(wxT("finished saving %s")) % m_filename);
}
开发者ID:tmphuang6,项目名称:amule,代码行数:45,代码来源:KnownFileList.cpp


示例15: sLock

//把backbuf的内容写入文件,如果有内容的话
VOID CLogFile::WriteBackBufToFile()
{
    CSmartLock sLock(m_lock);

    CheckLogFileStat();

    if (m_bBackBufAvailable)
    {
        std::ofstream logFile;
        logFile.open(m_szLogFileName, std::ios::app);
        INT outLen = strlen(m_pBackBuf);
        logFile.write(m_pBackBuf, (outLen>LOG_BUF_LEN)?LOG_BUF_LEN:outLen);
        logFile.close();

        *m_pBackBuf = '\0';
        m_bBackBufAvailable = FALSE;
    }
}
开发者ID:soho2515,项目名称:AsynRedisOperate,代码行数:19,代码来源:LogFile.cpp


示例16: checkIfUp

std::auto_ptr<mongo::DBClientCursor> MockRemoteDBServer::query(
    MockRemoteDBServer::InstanceID id,
    const string& ns,
    mongo::Query query,
    int nToReturn,
    int nToSkip,
    const BSONObj* fieldsToReturn,
    int queryOptions,
    int batchSize) {
    checkIfUp(id);

    if (_delayMilliSec > 0) {
        mongo::sleepmillis(_delayMilliSec);
    }

    checkIfUp(id);

    std::auto_ptr<mongo::DBClientCursor> cursor;

    scoped_spinlock sLock(_lock);
    _queryCount++;
    return cursor;
}
开发者ID:EricInBj,项目名称:mongo,代码行数:23,代码来源:mock_remote_db_server.cpp


示例17: GetAddressOwner

///////////////////////////////////////////////////////////////////////////
// CTSPIConferenceCall::CanRemoveFromConference
//
// Return true/false indicating whether the call may be removed
// from the conference.
//
bool CTSPIConferenceCall::CanRemoveFromConference(CTSPICallAppearance* pCall) const
{
    // Validate that the call being removed is in the conference.
    if (!IsCallInConference (pCall))
        return false;

    // If our address doesn't allow removal of conference parties, then error out.
    DWORD dwRemoveType = GetAddressOwner()->GetAddressCaps()->dwRemoveFromConfCaps;
    if (dwRemoveType == LINEREMOVEFROMCONF_NONE)
        return false;

    // If only the last party can be removed, make sure this is the last entry in the 
    // conference list.
    else if (dwRemoveType == LINEREMOVEFROMCONF_LAST)
    {
		CEnterCode sLock(this);  // Synch access to object
		if (pCall != m_lstConference.back())
			return false;
	}
    
    // Looks like we can remove it.
    return true;
    
}// CTSPIConferenceCall::CanRemoveFromConference
开发者ID:junction,项目名称:jn-tapi,代码行数:30,代码来源:Confcall.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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