本文整理汇总了C++中LockMut函数的典型用法代码示例。如果您正苦于以下问题:C++ LockMut函数的具体用法?C++ LockMut怎么用?C++ LockMut使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LockMut函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VolumesChanged
static OSStatus VolumesChanged( EventHandlerCallRef ref, EventRef event, void *p )
{
MemoryCardDriverThreaded_MacOSX *driver = (MemoryCardDriverThreaded_MacOSX *)p;
LockMut( driver->m_ChangedLock );
driver->m_bChanged = true;
return eventNotHandledErr; // let others do something
}
示例2: LockMut
bool BackgroundLoader::IsCacheFileFinished( const CString &sFile, CString &sActualPath )
{
if( !g_bEnableBackgroundLoading )
{
sActualPath = sFile;
return true;
}
LockMut( m_Mutex );
if( sFile == "" )
{
sActualPath = "";
return true;
}
map<CString,int>::iterator it;
it = m_FinishedRequests.find( sFile );
if( it == m_FinishedRequests.end() )
return false;
LOG->Trace("XXX: %s finished (%i)", sFile.c_str(), it->second);
if( g_bWriteToCache )
sActualPath = GetCachePath( sFile );
else
sActualPath = sFile;
return true;
}
示例3: LockMut
bool VirtualMemoryManager::EnsureFreeMemory(size_t size)
{
if(!inited)
return false;
LockMut(vmemMutex);
MEMORYSTATUS ms;
GlobalMemoryStatus(&ms);
while(ms.dwAvailPhys < size)
{
if(LOG && logging)
LOG->Trace("Freeing memory: need %i, have %i", size, ms.dwAvailPhys);
if(!DecommitLRU())
{
if(LOG)
LOG->Trace("VMem error: No pages left to free while reserving memory");
return false;
}
}
return true;
}
示例4: LockMut
void RageFileManager::GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bReturnPathToo )
{
LockMut( *g_Mutex );
NormalizePath( sPath );
for( unsigned i = 0; i < g_Drivers.size(); ++i )
{
LoadedDriver &ld = g_Drivers[i];
const CString p = ld.GetPath( sPath );
if( p.size() == 0 )
continue;
const unsigned OldStart = AddTo.size();
g_Drivers[i].driver->GetDirListing( p, AddTo, bOnlyDirs, bReturnPathToo );
/* If returning the path, prepend the mountpoint name to the files this driver returned. */
if( bReturnPathToo )
for( unsigned j = OldStart; j < AddTo.size(); ++j )
AddTo[j] = ld.MountPoint + AddTo[j];
}
/* More than one driver might return the same file. Remove duplicates (case-
* insensitively). */
sort( AddTo.begin(), AddTo.end(), ilt );
CStringArray::iterator it = unique( AddTo.begin(), AddTo.end(), ieq );
AddTo.erase(it, AddTo.end());
}
示例5: LockMut
RageFileObj *RageFileDriverMem::Open( const CString &sPath, int mode, RageFile &p, int &err )
{
LockMut(m_Mutex);
if( mode == RageFile::WRITE )
{
/* If the file exists, delete it. */
Remove( sPath );
RageFileObjMemFile *pFile = new RageFileObjMemFile;
m_Files.push_back( pFile );
FDB->AddFile( sPath, 0, 0, pFile );
return new RageFileObjMem( pFile, p );
}
RageFileObjMemFile *pFile = (RageFileObjMemFile *) FDB->GetFilePriv( sPath );
if( pFile == NULL )
{
err = ENOENT;
return NULL;
}
return new RageFileObjMem( pFile, p );
}
示例6: LockMut
void RageSound_Generic_Software::StopMixing( RageSoundBase *snd )
{
/* Lock, to make sure the decoder thread isn't running on this sound while we do this. */
LockMut( m_Mutex );
/* Find the sound. */
unsigned i;
for( i = 0; i < ARRAYSIZE(sounds); ++i )
if( !sounds[i].available && sounds[i].snd == snd )
break;
if( i == ARRAYSIZE(sounds) )
{
LOG->Trace( "not stopping a sound because it's not playing" );
return;
}
/* If we're already in STOPPED, there's nothing to do. */
if( sounds[i].state == sound::STOPPED )
{
LOG->Trace( "not stopping a sound because it's already in STOPPED" );
return;
}
// LOG->Trace("StopMixing: set %p (%s) to HALTING", sounds[i].snd, sounds[i].snd->GetLoadedFilePath().c_str());
/* Tell the mixing thread to flush the buffer. We don't have to worry about
* the decoding thread, since we've locked m_Mutex. */
sounds[i].state = sound::HALTING;
/* Invalidate the snd pointer to guarantee we don't make any further references to
* it. Once this call returns, the sound may no longer exist. */
sounds[i].snd = NULL;
// LOG->Trace("end StopMixing");
}
示例7: LockMut
void InputFilter::ButtonPressed( DeviceInput di, bool Down )
{
LockMut(*queuemutex);
if( di.ts.IsZero() )
LOG->Warn( "InputFilter::ButtonPressed: zero timestamp is invalid" );
if( di.device >= NUM_INPUT_DEVICES )
{
LOG->Warn( "Invalid device %i,%i", di.device, NUM_INPUT_DEVICES );
return;
}
if( di.button >= GetNumDeviceButtons(di.device) )
{
LOG->Warn( "Invalid button %i,%i", di.button, GetNumDeviceButtons(di.device) );
return;
}
ButtonState &bs = m_ButtonState[di.device][di.button];
RageTimer now;
CheckButtonChange( bs, di, now );
if( bs.m_BeingHeld != Down )
{
bs.m_BeingHeld = Down;
bs.m_BeingHeldTime = di.ts;
}
/* Try to report presses immediately. */
CheckButtonChange( bs, di, now );
}
示例8: int
void RageThread::Create( int (*fn)(void *), void *data )
{
/* Don't create a thread that's already running: */
ASSERT( m_pSlot == NULL );
InitThreads();
/* Lock unused slots, so nothing else uses our slot before we mark it used. */
LockMut(g_ThreadSlotsLock);
int slotno = FindEmptyThreadSlot();
m_pSlot = &g_ThreadSlots[slotno];
if( name == "" )
{
if( LOG )
LOG->Warn("Created a thread without naming it first.");
/* If you don't name it, I will: */
strcpy( m_pSlot->name, "Joe" );
} else {
strcpy( m_pSlot->name, name.c_str() );
}
if( LOG )
LOG->Trace( "Starting thread: %s", name.c_str() );
sprintf( m_pSlot->ThreadFormattedOutput, "Thread: %s", name.c_str() );
/* Start a thread using our own startup function. We pass the id to fill in,
* to make sure it's set before the thread actually starts. (Otherwise, early
* checkpoints might not have a completely set-up thread slot.) */
m_pSlot->pImpl = MakeThread( fn, data, &m_pSlot->id );
}
示例9: LockMut
void InputHandler_MacOSX_HID::DeviceAdded( void *refCon, io_iterator_t )
{
InputHandler_MacOSX_HID *This = (InputHandler_MacOSX_HID *)refCon;
LockMut( This->m_ChangeLock );
This->m_bChanged = true;
}
示例10: LockMut
void RageSoundDriver_ALSA9::StopMixing(RageSoundBase *snd)
{
/* Lock, to make sure the decoder thread isn't running on this sound while we do this. */
LockMut( m_Mutex );
ASSERT(snd != NULL);
unsigned i;
for( i = 0; i < stream_pool.size(); ++i )
if(stream_pool[i]->snd == snd)
break;
if( i == stream_pool.size() )
{
LOG->Trace("not stopping a sound because it's not playing");
return;
}
/* FLUSHING tells the mixer thread to release the stream once str->flush_bufs
* buffers have been flushed. */
stream_pool[i]->state = stream_pool[i]->FLUSHING;
/* Flush two buffers worth of data. */
stream_pool[i]->flush_pos = stream_pool[i]->pcm->GetPlayPos();
/* This function is called externally (by RageSoundBase) to stop immediately.
* We need to prevent SoundStopped from being called; it should only be
* called when we stop implicitely at the end of a sound. Set snd to NULL. */
stream_pool[i]->snd = NULL;
}
示例11: LockMut
RageFileBasic *RageFileDriverMem::Open( const CString &sPath, int mode, int &err )
{
LockMut(m_Mutex);
if( mode == RageFile::WRITE )
{
/* If the file exists, delete it. */
Remove( sPath );
RageFileObjMemFile *pFile = new RageFileObjMemFile;
/* Add one reference, representing the file in the filesystem. */
RageFileObjMemFile::AddReference( pFile );
m_Files.push_back( pFile );
FDB->AddFile( sPath, 0, 0, pFile );
return new RageFileObjMem( pFile );
}
RageFileObjMemFile *pFile = (RageFileObjMemFile *) FDB->GetFilePriv( sPath );
if( pFile == NULL )
{
err = ENOENT;
return NULL;
}
return new RageFileObjMem( pFile );
}
示例12: mut
struct tm *my_localtime_r( const time_t *timep, struct tm *result )
{
static RageMutex mut("my_localtime_r");
LockMut(mut);
*result = *localtime( timep );
return result;
}
示例13: LockMut
bool ArchHooks::AppFocusChanged()
{
LockMut( g_Mutex );
bool bFocusChanged = m_bFocusChanged;
m_bFocusChanged = false;
return bFocusChanged;
}
示例14: RemoveReference
void RemoveReference( const RageFileObj *obj )
{
LockMut( *g_Mutex );
FileReferences::iterator it = g_Refs.find( obj );
ASSERT_M( it != g_Refs.end(), ssprintf( "RemoveReference: Missing reference (%s)", obj->GetDisplayPath().c_str() ) );
g_Refs.erase( it );
}
示例15: LockMut
bool RageSound::SetPositionFrames( int iFrames )
{
LockMut( m_Mutex );
if( m_pSource == NULL )
{
LOG->Warn( "RageSound::SetPositionFrames(%d): sound not loaded", iFrames );
return false;
}
{
/* "m_iDecodePosition" records the number of frames we've output to the
* speaker. If the rate isn't 1.0, this will be different from the
* position in the sound data itself. For example, if we're playing
* at 0.5x, and we're seeking to the 10th frame, we would have actually
* played 20 frames, and it's the number of real speaker frames that
* "m_iDecodePosition" represents. */
const int iScaledFrames = int( iFrames / GetPlaybackRate() );
/* If we're already there, don't do anything. */
if( m_iDecodePosition == iScaledFrames )
return true;
m_iStoppedPosition = m_iDecodePosition = iScaledFrames;
}
/* The position we're going to seek the input stream to. We have
* to do this in floating point to avoid overflow. */
int ms = int( float(iFrames) * 1000.f / samplerate() );
ms = max(ms, 0);
m_DataBuffer.clear();
int ret;
if( m_Param.AccurateSync )
ret = m_pSource->SetPosition_Accurate(ms);
else
ret = m_pSource->SetPosition_Fast(ms);
if(ret == -1)
{
/* XXX untested */
Fail( m_pSource->GetError() );
return false; /* failed */
}
if(ret == 0 && ms != 0)
{
/* We were told to seek somewhere, and we got 0 instead, which means
* we passed EOF. This could be a truncated file or invalid data. */
LOG->Warn("SetPositionFrames: %i ms is beyond EOF in %s",
ms, GetLoadedFilePath().c_str());
return false; /* failed */
}
return true;
}