mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
MusicMod: Prepare to fix the MusicMod build
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3505 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
111
Externals/MusicMod/Player/Src/Lock.h
vendored
Normal file
111
Externals/MusicMod/Player/Src/Lock.h
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Plainamp, Open source Winamp core
|
||||
//
|
||||
// Copyright <20> 2005 Sebastian Pipping <webmaster@hartwork.org>
|
||||
//
|
||||
// --> http://www.hartwork.org
|
||||
//
|
||||
// This source code is released under the GNU General Public License (GPL).
|
||||
// See GPL.txt for details. Any non-GPL usage is strictly forbidden.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PA_LOCK_H
|
||||
#define PA_LOCK_H
|
||||
|
||||
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
|
||||
|
||||
// INFO: http://www.devarticles.com/c/a/Cplusplus/Multithreading-in-C/3/
|
||||
|
||||
|
||||
// #define LOCK_USES_MUTEX
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Lock for thread synchronization
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class Lock
|
||||
{
|
||||
public:
|
||||
Lock( TCHAR * szName );
|
||||
~Lock();
|
||||
|
||||
void Enter();
|
||||
void Leave();
|
||||
|
||||
private:
|
||||
#ifndef LOCK_USES_MUTEX
|
||||
CRITICAL_SECTION * m_pCrit;
|
||||
#else
|
||||
HANDLE hLock;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Creates a new named lock.
|
||||
/// Note: Don't use the same name for several locks
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
inline Lock::Lock( TCHAR * szName )
|
||||
{
|
||||
#ifndef LOCK_USES_MUTEX
|
||||
m_pCrit = new CRITICAL_SECTION;
|
||||
InitializeCriticalSection( m_pCrit );
|
||||
#else
|
||||
hLock = CreateMutex( NULL, TRUE, szName );
|
||||
ReleaseMutex( hLock );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
inline Lock::~Lock()
|
||||
{
|
||||
#ifndef LOCK_USES_MUTEX
|
||||
DeleteCriticalSection( m_pCrit );
|
||||
delete [] m_pCrit;
|
||||
#else
|
||||
CloseHandle( hLock );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Closes lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
inline void Lock::Enter()
|
||||
{
|
||||
#ifndef LOCK_USES_MUTEX
|
||||
EnterCriticalSection( m_pCrit );
|
||||
#else
|
||||
WaitForSingleObject( hLock, INFINITE );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Opens lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
inline void Lock::Leave()
|
||||
{
|
||||
#ifndef LOCK_USES_MUTEX
|
||||
LeaveCriticalSection( m_pCrit );
|
||||
#else
|
||||
ReleaseMutex( hLock );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // PA_LOCK_H
|
Reference in New Issue
Block a user