Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions filesystem/basefilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ void CBaseFileSystem::AddSearchPath( const char *pPath, const char *pathID, Sear
//-----------------------------------------------------------------------------
int CBaseFileSystem::GetSearchPath( const char *pathID, bool bGetPackFiles, OUT_Z_CAP(maxLenInChars) char *pDest, intp maxLenInChars )
{
AUTO_LOCK( m_SearchPathsMutex );
AUTO_LOCK_READ( m_SearchPathsMutex );

// Build up result into string object
// dimhotepus: Use std::string and reserve capacity.
Expand Down Expand Up @@ -1582,7 +1582,7 @@ CBaseFileSystem::CSearchPath *CBaseFileSystem::FindWritePath( const char *pFilen
{
CUtlSymbol lookup = g_PathIDTable.AddString( pathID );

AUTO_LOCK( m_SearchPathsMutex );
AUTO_LOCK_READ( m_SearchPathsMutex );

// a pathID has been specified, find the first match in the path list
intp c = m_SearchPaths.Count();
Expand Down Expand Up @@ -1964,7 +1964,7 @@ bool CBaseFileSystem::UnzipFile( const char *pFileName, const char *pPath, const
//-----------------------------------------------------------------------------
void CBaseFileSystem::RemoveAllSearchPaths( void )
{
AUTO_LOCK( m_SearchPathsMutex );
AUTO_LOCK_WRITE( m_SearchPathsMutex );
m_SearchPaths.Purge();
}

Expand Down
15 changes: 10 additions & 5 deletions filesystem/basefilesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,9 @@ abstract_class CBaseFileSystem : public CTier1AppSystem< IFileSystem >
if ( *ppszFilename && !Q_IsAbsolutePath( *ppszFilename ) )
{
// Copy paths to minimize mutex lock time
pFileSystem->m_SearchPathsMutex.Lock();
pFileSystem->m_SearchPathsMutex.LockForRead();
CopySearchPaths( pFileSystem->m_SearchPaths );
pFileSystem->m_SearchPathsMutex.Unlock();
pFileSystem->m_SearchPathsMutex.UnlockRead();

pFileSystem->FixUpPath ( *ppszFilename, m_Filename );
}
Expand Down Expand Up @@ -607,9 +607,9 @@ abstract_class CBaseFileSystem : public CTier1AppSystem< IFileSystem >
m_pathID = UTL_INVAL_SYMBOL;
}
// Copy paths to minimize mutex lock time
pFileSystem->m_SearchPathsMutex.Lock();
pFileSystem->m_SearchPathsMutex.LockForRead();
CopySearchPaths( pFileSystem->m_SearchPaths );
pFileSystem->m_SearchPathsMutex.Unlock();
pFileSystem->m_SearchPathsMutex.UnlockRead();
m_Filename[0] = '\0';
}

Expand Down Expand Up @@ -658,7 +658,12 @@ abstract_class CBaseFileSystem : public CTier1AppSystem< IFileSystem >
// logging functions
CUtlVector< FileSystemLoggingFunc_t > m_LogFuncs;

CThreadMutex m_SearchPathsMutex;
// RaphaelIT7: A CThreadRWLock/CThreadSpinRWLock should perform better than a CThreadFastMutex
#if defined(WIN32) || defined(_WIN32)
CThreadSpinRWLock m_SearchPathsMutex;
#else
CThreadRWLock m_SearchPathsMutex;
#endif
CUtlVector< CSearchPath > m_SearchPaths;
CUtlVector<CPathIDInfo*> m_PathIDInfos;
CUtlLinkedList<FindData_t> m_FindData;
Expand Down
Loading