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


C++ Lock函数代码示例

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


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

示例1: time

void LogUnixServer::Log(const LogType Type, const std::string &str) {
	char *msg = NULL;

	time_t current = time(NULL);
	struct tm timeinfo;
	char buf[128];

	localtime_r(&current, &timeinfo);
	strftime(buf, sizeof(buf), "%F %T", &timeinfo);

	if (asprintf(&msg, "%s - %s [PID: %d] - %s\n", buf, LogTypeToStr(Type).c_str(), getpid(), str.c_str()) < 0)
	{
		std::stringstream ss;
		ss << "asprintf failed error:" << strerror(errno);
		throw(LogException(ss.str()));
	}
	else
	{
		std::list<int> broken;
		int len = strlen(msg);

		Lock();

		for(auto fd : m_list)
		{
			ssize_t offset = 0;
			ssize_t ret = 0;
			do
			{
				ret = write(fd, msg + offset, len - offset);
				if (ret < 0)
				{
					switch(errno)
					{
						case EINTR:
							ret = 0; //Fudge this as if we didn't write anything
							break;
						default:
							break;
					}
				}
				else
				{
					offset += len;
				}
			} while(offset < len);

			if (ret < len || ret == 0)
			{
				broken.push_back(fd);
			}
		}

		//Kick any broken clients
		for(auto fd : broken)
		{
			if (close(fd) < 0)
			{
				abort();
			}
			m_list.remove(fd);
		}

		Unlock();

	}
	free(msg);
}
开发者ID:mistralol,项目名称:liblogger,代码行数:68,代码来源:LogUnixServer.cpp

示例2: Lock

void cProtocol125::SendUnloadChunk(int a_ChunkX, int a_ChunkZ)
{
	cCSLock Lock(m_CSPacket);
	SendPreChunk(a_ChunkX, a_ChunkZ, false);
}
开发者ID:RedEnraged96,项目名称:MCServer-1,代码行数:5,代码来源:Protocol125.cpp

示例3: Lock

bool CGPSController::IsKnownPosition() {
	Lock();
	bool ret = m_knownPosition;
	Unlock();
	return ret;
}
开发者ID:abmahmoodi,项目名称:rhodes,代码行数:6,代码来源:GeoLocationImpl.cpp

示例4: AcMainThread

// VPN Azure client main thread
void AcMainThread(THREAD *thread, void *param)
{
	AZURE_CLIENT *ac = (AZURE_CLIENT *)param;
	UINT last_ip_revision = INFINITE;
	UINT64 last_reconnect_tick = 0;
	UINT64 next_reconnect_interval = AZURE_CONNECT_INITIAL_RETRY_INTERVAL;
	UINT num_reconnect_retry = 0;
	UINT64 next_ddns_retry_tick = 0;
	bool last_connect_ok = false;
	// Validate arguments
	if (ac == NULL || thread == NULL)
	{
		return;
	}

	while (ac->Halt == false)
	{
		UINT64 now = Tick64();
		bool connect_was_ok = false;
		// Wait for enabling VPN Azure function
		if (ac->IsEnabled)
		{
			// VPN Azure is enabled
			DDNS_CLIENT_STATUS st;
			bool connect_now = false;
			bool azure_ip_changed = false;

			Lock(ac->Lock);
			{
				Copy(&st, &ac->DDnsStatus, sizeof(DDNS_CLIENT_STATUS));

				if (StrCmpi(st.CurrentAzureIp, ac->DDnsStatusCopy.CurrentAzureIp) != 0)
				{
					if (IsEmptyStr(st.CurrentAzureIp) == false)
					{
						// Destination IP address is changed
						connect_now = true;
						num_reconnect_retry = 0;
					}
				}

				if (StrCmpi(st.CurrentHostName, ac->DDnsStatusCopy.CurrentHostName) != 0)
				{
					// DDNS host name is changed
					connect_now = true;
					num_reconnect_retry = 0;
				}

				Copy(&ac->DDnsStatusCopy, &st, sizeof(DDNS_CLIENT_STATUS));
			}
			Unlock(ac->Lock);

			if (last_ip_revision != ac->IpStatusRevision)
			{
				last_ip_revision = ac->IpStatusRevision;

				connect_now = true;

				num_reconnect_retry = 0;
			}

			if (last_reconnect_tick == 0 || (now >= (last_reconnect_tick + next_reconnect_interval)))
			{
				UINT r;

				last_reconnect_tick = now;
				num_reconnect_retry++;
				next_reconnect_interval = (UINT64)num_reconnect_retry * AZURE_CONNECT_INITIAL_RETRY_INTERVAL;
				next_reconnect_interval = MIN(next_reconnect_interval, AZURE_CONNECT_MAX_RETRY_INTERVAL);

				r = (UINT)next_reconnect_interval;

				r = GenRandInterval(r / 2, r);

				next_reconnect_interval = r;

				connect_now = true;
			}

			if (IsEmptyStr(st.CurrentAzureIp) == false && IsEmptyStr(st.CurrentHostName) == false)
			{
				if (connect_now)
				{
					SOCK *s;
					char *host = NULL;
					UINT port = AZURE_SERVER_PORT;

					Debug("VPN Azure: Connecting to %s...\n", st.CurrentAzureIp);

					if (ParseHostPort(st.CurrentAzureIp, &host, &port, AZURE_SERVER_PORT))
					{
						if (st.InternetSetting.ProxyType == PROXY_DIRECT)
						{
							s = ConnectEx2(host, port, 0, (bool *)&ac->Halt);
						}
						else
						{
							s = WpcSockConnect2(host, port, &st.InternetSetting, NULL, AZURE_VIA_PROXY_TIMEOUT);
						}
//.........这里部分代码省略.........
开发者ID:455475876github,项目名称:SoftEtherVPN,代码行数:101,代码来源:AzureClient.c

示例5: assert

OMXPacket *OMXReader::Read()
{
  assert(!IsEof());
  
  AVPacket  pkt;
  OMXPacket *m_omx_pkt = NULL;
  int       result = -1;

  if(!m_pFormatContext)
    return NULL;

  Lock();

  // assume we are not eof
  if(m_pFormatContext->pb)
    m_pFormatContext->pb->eof_reached = 0;

  // keep track if ffmpeg doesn't always set these
  pkt.size = 0;
  pkt.data = NULL;
  pkt.stream_index = MAX_OMX_STREAMS;

  result = m_dllAvFormat.av_read_frame(m_pFormatContext, &pkt);
  if (result < 0)
  {
    m_eof = true;
    //FlushRead();
    //m_dllAvCodec.av_free_packet(&pkt);
    UnLock();
    return NULL;
  }
  else if (pkt.size < 0 || pkt.stream_index >= MAX_OMX_STREAMS)
  {
    // XXX, in some cases ffmpeg returns a negative packet size
    if(m_pFormatContext->pb && !m_pFormatContext->pb->eof_reached)
    {
      CLog::Log(LOGERROR, "OMXReader::Read no valid packet");
      //FlushRead();
    }

    m_dllAvCodec.av_free_packet(&pkt);

    m_eof = true;
    UnLock();
    return NULL;
  }

  AVStream *pStream = m_pFormatContext->streams[pkt.stream_index];

  /* only read packets for active streams */
  /*
  if(!IsActive(pkt.stream_index))
  {
    m_dllAvCodec.av_free_packet(&pkt);
    UnLock();
    return NULL;
  }
  */

  // lavf sometimes bugs out and gives 0 dts/pts instead of no dts/pts
  // since this could only happens on initial frame under normal
  // circomstances, let's assume it is wrong all the time
  if(pkt.dts == 0)
    pkt.dts = AV_NOPTS_VALUE;
  if(pkt.pts == 0)
    pkt.pts = AV_NOPTS_VALUE;

  if(m_bMatroska && pStream->codec && pStream->codec->codec_type == AVMEDIA_TYPE_VIDEO)
  { // matroska can store different timestamps
    // for different formats, for native stored
    // stuff it is pts, but for ms compatibility
    // tracks, it is really dts. sadly ffmpeg
    // sets these two timestamps equal all the
    // time, so we select it here instead
    if(pStream->codec->codec_tag == 0)
      pkt.dts = AV_NOPTS_VALUE;
    else
      pkt.pts = AV_NOPTS_VALUE;
  }
  // we need to get duration slightly different for matroska embedded text subtitels
  if(m_bMatroska && pStream->codec->codec_id == AV_CODEC_ID_SUBRIP && pkt.convergence_duration != 0)
    pkt.duration = pkt.convergence_duration;

  if(m_bAVI && pStream->codec && pStream->codec->codec_type == AVMEDIA_TYPE_VIDEO)
  {
    // AVI's always have borked pts, specially if m_pFormatContext->flags includes
    // AVFMT_FLAG_GENPTS so always use dts
    pkt.pts = AV_NOPTS_VALUE;
  }

  m_omx_pkt = AllocPacket(pkt.size);
  /* oom error allocation av packet */
  if(!m_omx_pkt)
  {
    m_eof = true;
    m_dllAvCodec.av_free_packet(&pkt);
    UnLock();
    return NULL;
  }

//.........这里部分代码省略.........
开发者ID:acieroid,项目名称:omxplayer,代码行数:101,代码来源:OMXReader.cpp

示例6: Lock

int CFileLoaderThread::DoThreadWork()
{
	int i;
	// Check for shutdown event
	if ( WAIT_OBJECT_0 == WaitForSingleObject( GetShutdownHandle(), 0 ) )
	{
		return 0;
	}

	// No changes to list right now
	Lock();
	// Move new items to work list
	int newItems = m_FileList.Count();
	for ( i = 0; i < newItems; i++ )
	{
		// Move to pending and issue async i/o calls
		m_Pending.AddToTail( m_FileList[ i ] );

		m_nTotalPending++;
	}
	m_FileList.RemoveAll();
	// Done adding new work items
	Unlock();

	int remaining = m_Pending.Count();
	if ( !remaining )
		return 1;

	int workitems = remaining; // min( remaining, 1000 );

	CUtlVector< SentenceRequest * > transfer;

	for ( i = 0; i < workitems; i++ )
	{
		SentenceRequest *r = m_Pending[ 0 ];
		m_Pending.Remove( 0 );

		transfer.AddToTail( r );
		// Do the work
		
		m_nTotalProcessed++;

		r->valid = SceneManager_LoadSentenceFromWavFileUsingIO( r->filename, r->sentence, m_ThreadIO );
	}

	// Now move to completed list
	Lock();
	for ( i = 0; i < workitems; i++ )
	{
		SentenceRequest *r = transfer[ i ];
		if ( r->valid )
		{
			m_nTotalCompleted++;

			m_Completed.AddToTail( r );
		}
		else
		{
			delete r;
		}
	}
	Unlock();
	return 1;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:64,代码来源:fileloaderthread.cpp

示例7: Lock

//-----------------------------------------------------------------------------
// Purpose: Input handler that locks the door.
//-----------------------------------------------------------------------------
void CBaseDoor::InputLock( inputdata_t &inputdata )
{
	Lock();
}
开发者ID:KyleGospo,项目名称:City-17-Episode-One-Source,代码行数:7,代码来源:doors.cpp

示例8: Lock

void CDVDPerformanceCounter::DeInitialize()
{
  Lock();
  
  Unlock();
}
开发者ID:Avoidnf8,项目名称:xbmc-fork,代码行数:6,代码来源:DVDPerformanceCounter.cpp

示例9: while

inline void Factory::run()
{
	DeviceParamMap paramMap;
	/* Create the thread to update the Disk status */
	while (1)
	{
		paramMap.clear();
		{
			/* Got all the device param */
			Lock();
			DeviceMap::iterator it = m_DeviceMap.begin(); 
			for(; it!=m_DeviceMap.end(); ++it)
			{	
				s32 nIndex = (*it).first;
				DeviceParam pParam;
				Device *pDevice = m_DeviceMap[nIndex];
				if (pDevice == NULL)
				{
					continue;//TODO
				}
				pDevice->GetDeviceParam(pParam);
				paramMap[nIndex] = pParam;
			}
			UnLock();
		}
		{
			/* Loop all the deviceparam */
			DeviceParamMap::iterator it = paramMap.begin(); 
			for(; it!=paramMap.end(); ++it)
			{	
				/* Loop to check the device and update the url */
				s32 nIndex = (*it).first;
				(*it).second.m_wipOnline = (*it).second.CheckOnline();
				if ((*it).second.m_OnlineUrl == FALSE)
				{
					(*it).second.m_wipOnlineUrl = (*it).second.UpdateUrl();
				}
			}
		}
		{
			/* Loop all the deviceparam result and set to device */
			DeviceParamMap::iterator it = paramMap.begin(); 
			for(; it!=paramMap.end(); ++it)
			{	
				/* Loop to check the device and update the url */
				s32 nIndex = (*it).first;
				Lock();
				DeviceMap::iterator it1 = m_DeviceMap.find(nIndex), 
							ite1 = m_DeviceMap.end();

				if (it1 == ite1) 
				{
					/* the id may be delete */
					UnLock();
					continue;
				}

				DeviceStatus bCheck = m_DeviceMap[nIndex]->CheckDevice(
					(*it).second.m_strUrl, (*it).second.m_strUrlSubStream, 
					(*it).second.m_bHasSubStream, 
					(*it).second.m_wipOnline, (*it).second.m_wipOnlineUrl);
				
				FactoryDeviceChangeData change;
				change.id = nIndex;
				switch (bCheck)
				{
					case DEV_OFF2ON:
					{
						change.type = FACTORY_DEVICE_ONLINE;
						m_DeviceOnlineMap[nIndex] = 1;
						UnLock(); 
						CallDeviceChange(change);
						Lock();
						break;
					}
					case DEV_ON2OFF:
					{
						change.type = FACTORY_DEVICE_OFFLINE;
						m_DeviceOnlineMap[nIndex] = 0;
						UnLock(); 
						CallDeviceChange(change);
						Lock();
						break;
					}
					default:
					{

						break;
					}
				}
				UnLock();
			}
		}
		ve_sleep(1000 * 20);
	}
	
}
开发者ID:babosa,项目名称:opencvr,代码行数:97,代码来源:factoryimpl.hpp

示例10: Lock

ECRESULT ECSessionGroup::AddNotificationTable(ECSESSIONID ulSessionId, unsigned int ulType, unsigned int ulObjType, unsigned int ulTableId,
											  sObjectTableKey* lpsChildRow, sObjectTableKey* lpsPrevRow, struct propValArray *lpRow)
{
	ECRESULT hr = erSuccess;

	Lock();

	struct notification *lpNotify = new struct notification;
	memset(lpNotify, 0, sizeof(notification));

	lpNotify->tab = new notificationTable;
	memset(lpNotify->tab, 0, sizeof(notificationTable));
	
	lpNotify->ulEventType			= fnevTableModified;
	lpNotify->tab->ulTableEvent		= ulType;


	if(lpsChildRow && (lpsChildRow->ulObjId > 0 || lpsChildRow->ulOrderId > 0)) {
		lpNotify->tab->propIndex.ulPropTag = PR_INSTANCE_KEY;
		lpNotify->tab->propIndex.__union = SOAP_UNION_propValData_bin;
		lpNotify->tab->propIndex.Value.bin = new struct xsd__base64Binary;
		lpNotify->tab->propIndex.Value.bin->__ptr = new unsigned char[sizeof(ULONG)*2];
		lpNotify->tab->propIndex.Value.bin->__size = sizeof(ULONG)*2;

		memcpy(lpNotify->tab->propIndex.Value.bin->__ptr, &lpsChildRow->ulObjId, sizeof(ULONG));
		memcpy(lpNotify->tab->propIndex.Value.bin->__ptr+sizeof(ULONG), &lpsChildRow->ulOrderId, sizeof(ULONG));
	}else {
		lpNotify->tab->propIndex.ulPropTag = PR_NULL;
		lpNotify->tab->propIndex.__union = SOAP_UNION_propValData_ul;
	}

	if(lpsPrevRow && (lpsPrevRow->ulObjId > 0 || lpsPrevRow->ulOrderId > 0))
	{
		lpNotify->tab->propPrior.ulPropTag = PR_INSTANCE_KEY;
		lpNotify->tab->propPrior.__union = SOAP_UNION_propValData_bin;
		lpNotify->tab->propPrior.Value.bin = new struct xsd__base64Binary;
		lpNotify->tab->propPrior.Value.bin->__ptr = new unsigned char[sizeof(ULONG)*2];
		lpNotify->tab->propPrior.Value.bin->__size = sizeof(ULONG)*2;

		memcpy(lpNotify->tab->propPrior.Value.bin->__ptr, &lpsPrevRow->ulObjId, sizeof(ULONG));
		memcpy(lpNotify->tab->propPrior.Value.bin->__ptr+sizeof(ULONG), &lpsPrevRow->ulOrderId, sizeof(ULONG));

	}else {
		lpNotify->tab->propPrior.__union = SOAP_UNION_propValData_ul;
		lpNotify->tab->propPrior.ulPropTag = PR_NULL;
	}
	
	lpNotify->tab->ulObjType = ulObjType;

	if(lpRow) {
		lpNotify->tab->pRow = new struct propValArray;
		lpNotify->tab->pRow->__ptr = lpRow->__ptr;
		lpNotify->tab->pRow->__size = lpRow->__size;
	}

	AddNotification(lpNotify, ulTableId, 0, ulSessionId);

	//Free by lpRow
	if(lpNotify->tab->pRow){
		lpNotify->tab->pRow->__ptr = NULL;
		lpNotify->tab->pRow->__size = 0;
	}

	//Free struct
	FreeNotificationStruct(lpNotify);

	Unlock();

	return hr;
}
开发者ID:agx,项目名称:zarafa-debian,代码行数:70,代码来源:ECSessionGroup.cpp

示例11: Lock

void CStringz::Refresh() {
	if (mh) {
		Lock();
		UnLock();
	}
}
开发者ID:akrisiun,项目名称:VfpProj,代码行数:6,代码来源:cstringz.cpp

示例12: m_BSM_Init


//.........这里部分代码省略.........
	//	hr = CVR_EscapeCtrl(m_pVr,TITAN_DSP_RENDERER,0,0,0);
	//	if(hr!=VR_OK)
	//	{
	//		// do something here.
	//	}
	//}
	//else
	{
//		alignx = 2; /* actually 2, but we prefer this for our averaging ops */
//		aligny = 2;

	}
	buffers = m_dwMaxBuffers+1;
	wpad = ~(m_dwWidth-1) & (ALIGNX-1);
	width = m_dwWidth+wpad;
	height = m_dwHeight*m_sy;
	hpad = ~(height-1) & (ALIGNY-1);
	height = height+hpad;
	//width = width + (width&0xf);
	//height = height + (height&0xf);
	//SetDisplayMode(1);


	m_iYPitch = width;
	m_iUVPitch = m_iYPitch>>1;
	//hr = CVR_SetVideoFormat(m_pVr, 0, width, height, 0, &m_iYPitch, &m_iUVPitch);
		//Set the Video parameters. 
	//VR_FORMAT_I420: set the input data format as I420  
	//width: width of source frame 
	//height: height of source frame 
	//rect: the source rect 
	//LumPitch: pitch of lum 
	//ChromPitch: pitch of chrom 

	width = ROOF(m_dwWidth, ALIGNX);

	if(m_bBSMMode == TRUE)
		height = ROOF(m_dwHeight, ALIGNY);
	else
		height = m_dwHeight;

	VR_SRCRECT rect;
	rect.left= 0;
	rect.right = m_dwWidth;
	rect.top = 0;
	rect.bottom= m_dwHeight;

	hr = m_CVR_SetVideoFormat(m_pVr, VR_FORMAT_I420, width, height, &rect,  &m_iYPitch, &m_iUVPitch);

	SetDeinterlaceMode(m_deinterlace_mode);

    if(!m_bBSMMode)
    {
	    m_pBackBuffer = new LPVR_FRAME_SURFACE[buffers];
	    ZeroMemory(m_pBackBuffer,sizeof(m_pBackBuffer[0])*buffers);

	    for(i=0;i<(signed)buffers;i++)
	    {
		    hr = m_CVR_CreateSurface(m_pVr,&m_pBackBuffer[i],1);
		    if(hr!=VR_OK)
			    break;
	    }
	    if(i==0)
	    {
		    delete[] m_pBackBuffer;
		    m_pBackBuffer = 0;
		    //CVR_DeleteVideoRender(m_pVr);
		    //m_pVr = 0;
		    return E_FAIL;
	    }

	    if(i>1)
	    {		// make sure we have at least one surface available for background scratch, otherwise hang.
		    m_CVR_DestroySurface(m_pVr,m_pBackBuffer[--i]);
		    ZeroMemory(&m_pBackBuffer[i],sizeof(m_pBackBuffer[i]));
	    }

	    m_dwBackBuffers = i;

	    // clear out buffers
	    unsigned char *pb;
	    LONG lstride;
	    int xl,xr,yt,yb,ht;

	    yt = hpad>>1&~1;
	    yb = hpad - yt;
	    xl = 0; // (wpad>>1)&~3;
	    xr = wpad -xl;
	    ht = m_dwHeight*m_sy;

	    for(i=0;i<(signed)m_dwBackBuffers;i++)
	    {
		    if(SUCCEEDED(Lock(i, (LPVOID *)&pb, &lstride, 0)))
		    {
			    clearoutsiderect(pb,m_dwWidth,ht,lstride,0,xl,xr,yt,yb);
			    clearoutsiderect(pb+height*width,m_dwWidth>>1,ht>>1,lstride>>1,128,xl>>1,xr>>1,yt>>1,yb>>1);
			    clearoutsiderect(pb+height*width+(height*width>>2),m_dwWidth>>1,ht>>1,lstride>>1,128,xl>>1,xr>>1,yt>>1,yb>>1);
			    Unlock(i);
		    }
	    }
开发者ID:xuweiqiang,项目名称:LibVRPresent,代码行数:101,代码来源:GfxTitanII.cpp

示例13: __KTRACE_OPT

TInt DPowerManager::PowerDown()
	{ // called by ExecHandler 
	__KTRACE_OPT(KPOWER,Kern::Printf(">PowerManger::PowerDown(0x%x) Enter", iPowerController->iTargetState));
	__ASSERT_CRITICAL;

	Lock();


	if (iPowerController->iTargetState == EPwActive)
		{
		Unlock();
		return KErrNotReady;
		}

    __PM_ASSERT(iHandlers);
	NFastSemaphore shutdownSem(0);
	NTimer ntimer;
	TDfc dfc(ShutDownTimeoutFn, &shutdownSem);
#ifndef _DEBUG_POWER	
	iPendingShutdownCount = 0;
#endif	
	DPowerHandler* ph = iHandlers;
	//Power down in reverse order of handle registration.
	do
		{
#ifdef _DEBUG_POWER
		__PM_ASSERT(!(ph->iStatus & DPowerHandler::EDone));
#endif
		ph->iSem = &shutdownSem; 
		ph->PowerDown(iPowerController->iTargetState);
#ifndef _DEBUG_POWER		
		iPendingShutdownCount++; 
#else
		if(iPslShutdownTimeoutMs>0)
			{
		    // Fire shut down timeout timer			
			ntimer.OneShot(iPslShutdownTimeoutMs, dfc);
			}

		NKern::FSWait(&shutdownSem);	// power down drivers one after another to simplify debug
		__e32_atomic_and_ord32(&(ph->iStatus), ~DPowerHandler::EDone);

		// timeout condition
		if(iPslShutdownTimeoutMs>0 && ph->iSem)
			{
			__e32_atomic_store_ord_ptr(&ph->iSem, 0);
			}
		ntimer.Cancel();
#endif		
		ph = ph->iPrev;
		}while(ph != iHandlers);

#ifndef _DEBUG_POWER
	if(iPslShutdownTimeoutMs>0)
		{
		// Fire shut down timeout timer
		ntimer.OneShot(iPslShutdownTimeoutMs, dfc);
		}

	ph = iHandlers;
	do
		{
		NKern::FSWait(&shutdownSem);
		if(__e32_atomic_load_acq32(&iPendingShutdownCount)==ESHUTDOWN_TIMEOUT)
			{
			iPendingShutdownCount = 0;
			NKern::Lock();
			shutdownSem.Reset(); // iPendingShutdownCount could be altered while ShutDownTimeoutFn is running
		       			     // reset it to make sure shutdownSem is completely clean.	
			NKern::Unlock();
			break;
			}
		__e32_atomic_add_ord32(&iPendingShutdownCount, (TUint)(~0x0)); // iPendingShutDownCount--;
		ph = ph->iPrev;
		}while(ph != iHandlers);

	ntimer.Cancel();
	
#endif

	TTickQ::Wait();

	iPowerController->PowerDown(K::SecondQ->WakeupTime());
	__PM_ASSERT(iPowerController->iTargetState != EPwOff);
	iPowerController->iTargetState = EPwActive;

	K::SecondQ->WakeUp();
	TTickQ::Signal();

	NFastSemaphore powerupSem(0);

	ph = iHandlers->iNext;
	//Power up in same order of handle registration.
	do
		{
#ifdef _DEBUG_POWER
		__PM_ASSERT(!(ph->iStatus & DPowerHandler::EDone));
#endif
		ph->iSem = &powerupSem;
		ph->PowerUp();
//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:101,代码来源:power.cpp

示例14: file


//.........这里部分代码省略.........
					// antes de continuar o loop, sair e entrar
					// novamente em regiao critica, para possibilitar
					// outros threads rodarem
					cCS0.LeaveCriticalSection();
					cCS0.EnterCriticalSection();
					continue;
				}
				if( errno != EMFILE ){
					iFile = -1;
					return( !OK );
				}
			} else {
				if( GetLastError() == ERROR_ALREADY_EXISTS && (dwCreateMode == CREATE_NEW) ){
					// ************************************************************
					// ATENCAO:
					// ************************************************************
					// nao tentar fechar outro arquivo para reabrir este se 
					// GetLastError() == ERROR_ALREADY_EXISTS && (dwCreateMode == CREATE_NEW)
					// ************************************************************
					return( !OK );
				}
				if( GetLastError() == ERROR_SHARING_VIOLATION && bWait ){
					// o arquivo nao foi aberto porque estah sendo
					// usado por outro processo em modo exclusivo.
					// esperar um pouco e tentar novamente
					Sleep( 1000 );	// 1 segundo
					hFile = INVALID_HANDLE_VALUE;
					iFile = -1;

					// antes de continuar o loop, sair e entrar
					// novamente em regiao critica, para possibilitar
					// outros threads rodarem
					cCS0.LeaveCriticalSection();
					cCS0.EnterCriticalSection();
					continue;
				}
				if( GetLastError() != ERROR_TOO_MANY_OPEN_FILES ){
#ifdef _USE_PRINTF_
					Printf( "C_File: Deu um erro doidao no Open." );
					Printf( "C_File: Fudeu em <%s>", szNameFile );
#endif
					hFile = INVALID_HANDLE_VALUE;
					iFile = -1;
					return( !OK );
				}
			}
#ifdef _USE_PRINTF_
			Printf( "C_File: Muitos arquivos abertos. Vou terminar." );
#endif
			return( !OK );
		}
	} while ( (_bIs32s && iFile == -1) || (!_bIs32s && hFile == INVALID_HANDLE_VALUE) );
	if( this == _xFile ){
		Seek( 0, SEEK_SET );
		char	szCaca[ 50 ];
		sprintf( szCaca, "%d", ++_iNumXDat );
		Write( szCaca, strlen( szCaca ) );
		Seek( 0, SEEK_SET );
		Lock( strlen( szCaca ) );
#ifdef _USE_PRINTF_
		Printf( "C_File: Abri o _xFile****************************" );
#endif
	}
	if( strstr( szMode, "a" ) != NULL ){
		Seek( 0L, SEEK_END );
	}
	Hash();
	_iNumOpenFiles++;
#ifdef _USE_PRINTF_
	Printf( "C_File: Abri o arquivo <%d> (nome = <%s> - handle = <%d>)", _iNumOpenFiles, szNameFile ? szNameFile : "NULL", _bIs32s ? iFile : (int) hFile );
#endif

	// MMF: apenas se nao for 32s e se iHeadSize estiver setado para um valor maior que 0
	if( !_bIs32s && iHeadSize > 0 ){
		// pegar o tamanho da janela no .ini
		char	szFullIniName[ MAXPATH ];

		GetAppFullPath( szFullIniName, MAXPATH );


		iMMFWinSize = GetPrivateProfileInt( CONFIG_SESSION, WINDOWSIZE_KEY, 
											WINDOWSIZE_DEFAULT, szFullIniName );

		// se o tamanho da janela for <= 0, significa que o usuario nao quer usar MMF
		hMMF = NULL;
		if( iMMFWinSize > 0 ){
			hMMF = CreateFileMapping( hFile, NULL,
				(dwAccess & GENERIC_WRITE) ? PAGE_READWRITE : PAGE_READONLY,
				0, 0, NULL );
		}
		pHeadView = NULL;
		pWinView = NULL;
		iWinNum = 0;
		iSeekWin = 0;
	}

	bRealLock = _bStaticRealLock;

	return( OK );
}
开发者ID:softwarepublico,项目名称:lightbase,代码行数:101,代码来源:WDFILECL.CPP

示例15: Lock

void cRoot::QueueExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallback & a_Output)
{
	// Put the command into a queue (Alleviates FS #363):
	cCSLock Lock(m_CSPendingCommands);
	m_PendingCommands.emplace_back(a_Cmd, &a_Output);
}
开发者ID:beeduck,项目名称:cuberite,代码行数:6,代码来源:Root.cpp


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