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


C++ CriticalSection类代码示例

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


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

示例1: while

//
//	Given a buffer of size DWORDs, populates the buffer with
//	the thread IDs of all currently active lisp threads.
//	Returns the number of thread IDs actually stored in the buffer.
//
DWORD LispThreadQueue::GetLispThreadIDs(DWORD* buf, int size)
{
	TQCriticalSection.Enter();
	ThreadRecord* tr = list;
	int i = 0;
	while (tr && i < size)
	{
		buf[i++] = tr->threadID;
		tr = tr->next;
	}
	TQCriticalSection.Leave();
	return i;
}
开发者ID:dnm,项目名称:cormanlisp,代码行数:18,代码来源:LispThreadQueue.cpp

示例2: while

    CSSet FMLPAnalysis::short_outermost_cs(CSSet::const_iterator begin, CSSet::const_iterator end) const
    {
        stack<CriticalSection> s;
        for (auto i = begin; i != end; ++i) s.push(*i);
        CSSet work;
        while(s.size() >0) {
            CriticalSection cs = s.top();
            s.pop();
            Resource r = get_res(cs.get_resource());
            if (r.is_short()) work.push_back(cs);
            else 
                for (auto i = cs.begin(); i!=cs.end(); ++i) s.push(*i);
        }

        return work;
    }
开发者ID:italianoan,项目名称:rtscan,代码行数:16,代码来源:fmlp.cpp

示例3: getOutputBuffer

	void LogMgr::log(const std::string& tag, const std::string& message, const char* funcName, const char* sourceFile, unsigned int lineNum)
	{
		m_TagCriticalSection.lock();
		Tags::iterator findIt = m_Tags.find(tag);
		if (findIt != m_Tags.end())
		{
			m_TagCriticalSection.unlock();

			std::string buffer;
			getOutputBuffer(buffer, tag, message, funcName, sourceFile, lineNum);
			outputFinalBufferToLogs(buffer, tag, findIt->second);
		}
		else
		{
			m_TagCriticalSection.unlock();
		}
	}
开发者ID:paubertin,项目名称:xTen,代码行数:17,代码来源:logger.cpp

示例4: setDisplayFLags

	void LogMgr::setDisplayFLags(const std::string& tag, unsigned char flags)
	{
		m_TagCriticalSection.lock();
		if (flags != 0)
		{
			Tags::iterator findIt = m_Tags.find(tag);
			if (findIt == m_Tags.end())
				m_Tags.insert(std::make_pair(tag, flags));
			else
				findIt->second = flags;
		}
		else
		{
			m_Tags.erase(tag);
		}
		m_TagCriticalSection.unlock();
	}
开发者ID:paubertin,项目名称:xTen,代码行数:17,代码来源:logger.cpp

示例5: GetOutputBuffer

//------------------------------------------------------------------------------------------------------------------------------------
// This function builds up the log string and outputs it to various places based on the display flags (m_displayFlags).
//------------------------------------------------------------------------------------------------------------------------------------
void LogMgr::Log(const string& tag, const string& message, const char* funcName, const char* sourceFile, unsigned int lineNum)
{
	m_tagCriticalSection.Lock();
	Tags::iterator findIt = m_tags.find(tag);
	if (findIt != m_tags.end())
	{
		m_tagCriticalSection.Unlock();
		
		string buffer;
		GetOutputBuffer(buffer, tag, message, funcName, sourceFile, lineNum);
		OutputFinalBufferToLogs(buffer, findIt->second);
	}
	else
	{
		// Critical section is exited in the if statement above, so we need to exit it here if that didn't 
		// get executed.
        m_tagCriticalSection.Unlock();
	}
}  // end LogMgr::Log()
开发者ID:AsbjoernS,项目名称:gamecode4,代码行数:22,代码来源:Logger.cpp

示例6: MutexListList_GetID

int MutexListList_GetID(CriticalSection *mutexPointer)
{
	queuelistmutex.enter();
	MutexList_t *temp = MutexList;
	int returnID = -1;
	
	while (temp != NULL)
	{
		if (temp->mutexPointer == mutexPointer)
		{
			returnID = temp->mutexID;
			break;
		}
		
		temp = temp->next;
	}
	queuelistmutex.exit();
	
	return returnID;
}
开发者ID:gillspice,项目名称:mios32,代码行数:20,代码来源:JUCEqueue.cpp

示例7: dequeue

		bool dequeue( _Tx *out )
		{
			bool success = false;
			m_cs.Enter();
			if (m_queue.size() > 0) {
				*out = m_queue.front();
				m_queue.pop();
				success = true;
			}
			m_cs.Exit();
			return success;
		}
开发者ID:2bitdreamer,项目名称:SD6_Engine,代码行数:12,代码来源:ThreadSafeQueue.hpp

示例8: FlushAll

 // Flush all existing thread streams... returns false on socket error
 bool AsyncStream::FlushAll(Socket &s)
 {
     OVR_CAPTURE_CPU_ZONE(AsyncStream_FlushAll);
     bool okay = true;
     g_listlock.Lock();
     for(AsyncStream *curr=s_head; curr; curr=curr->m_next)
     {
         okay = curr->Flush(s);
         if(!okay) break;
     }
     g_listlock.Unlock();
     return okay;
 }
开发者ID:beijingkaka,项目名称:shellspace,代码行数:14,代码来源:OVR_Capture_AsyncStream.cpp

示例9: push

 bool push(const _et &element,long timeout)
 {
     if (free_space.wait(timeout) ) {
         c_region.enter();
         int next = (last + 1) % element_count;
         elements[last] = element;
         last = next;
         active_buffers++;
         c_region.leave();
         data_avail.signal();
         return true;
     }
     return false;
 }
开发者ID:RogerDev,项目名称:HPCC-Platform,代码行数:14,代码来源:udpsha.hpp

示例10: release

int ServiceManager::release(void *svcptr) {
  if (svcptr == NULL) return 0;

  waServiceFactory *wsvc = NULL;
  cs.enter();	// note cs getting locked twice via release+unlock
  if (!lockmap.getItem(svcptr, &wsvc)) {
    cs.leave();
    DebugString("WARNING: got release with no lock record!");
    return 0;
  }
  unlock(svcptr);
  cs.leave();

  ASSERT(wsvc != NULL);
  return wsvc->releaseInterface(svcptr);
}
开发者ID:bizzehdee,项目名称:wasabi,代码行数:16,代码来源:svcmgr.cpp

示例11: spiInitialize

  //------------------------------------------------------------------------------------------------------------------------------------
  bool __stdcall spiInitialize( client_info *gameClientInfo, 
                                user_info *userData, 
                                battle_info *bnCallbacks, 
                                module_info *moduleData, 
                                HANDLE hEvent)
  {
    // Called when the module is loaded
//    DropMessage(0, "spiInitialize");

    fatalError = false;
    gameAppInfo = *gameClientInfo;

    receiveEvent = hEvent;

    critSec.init();

    try
    {
      pluggedNetwork->initialize();
    }
    catch(GeneralException &e)
    {
      fatalError = true;
      DropLastError(__FUNCTION__ " unhandled exception: %s", e.getMessage());
      return false;
    }

    return true;
  }
开发者ID:AdamKotynia,项目名称:bwapi,代码行数:30,代码来源:SNPModule.cpp

示例12: safeExit

void safeExit(int retcode)
{
	bool shutdown;

	globalMutex.lock(false);
	shutdown=deadYet;
	if(!deadYet)
	{
		deadYet=true;
		cleanup();
		fconfig_deleteinstance();
	}
	globalMutex.unlock(false);
	if(!shutdown) exit(retcode);
	else pthread_exit(0);
}
开发者ID:nathankidd,项目名称:virtualgl,代码行数:16,代码来源:faker.cpp

示例13: unlock

	void unlock()
	{
#ifdef DEBUG
		if (!locked) throw "Already unlocked";
#endif
		cs->leave();
		locked = false;
	}
开发者ID:CyberShadow,项目名称:DDD,代码行数:8,代码来源:sync_winapi.cpp

示例14: Log

///////////////////////////////////////////////////////////////////////////////////////////////////////
// this function builds up the log string and outputs it to various places based on display flags
///////////////////////////////////////////////////////////////////////////////////////////////////////
void LogMgr::Log(const string& tag, const string& message, const char* func, const char* source, unsigned int line)
{
  _tag_critical_section.Lock();
  Tags::iterator it = _tags.find(tag);
  if(it != _tags.end())
  {
    _tag_critical_section.Unlock();
    string buffer;
    GetOutputBuffer(buffer, tag, message, func, source, line);
    OutputFinalBufferToLogs(buffer, it->second);
  }
  else
  {
    //critical section is exited in the if above, so need to do it here if above wasnt executed
    _tag_critical_section.Unlock();
  }
}
开发者ID:raistlin969,项目名称:Solinari,代码行数:20,代码来源:Logger.cpp

示例15: lock

	void lock()
	{
#ifdef DEBUG
		if (locked) throw "Already locked";
#endif
		cs->enter();
		locked = true;
	}
开发者ID:CyberShadow,项目名称:DDD,代码行数:8,代码来源:sync_winapi.cpp


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