Version

menu_open
Target Platform(s):

include/AK/Tools/Win32/AkLock.h

Go to the documentation of this file.
00001 
00002 //
00003 // AkLock.h
00004 //
00005 // AudioKinetic Lock class
00006 //
00007 // Copyright (c) 2006 Audiokinetic Inc. / All Rights Reserved
00008 //
00010 
00011 #ifndef _AKLOCK_H_
00012 #define _AKLOCK_H_
00013 
00014 #include <AK/SoundEngine/Common/AkTypes.h>
00015 #include <windows.h>    //For CRITICAL_SECTION
00016 
00017 //-----------------------------------------------------------------------------
00018 // CAkLock class
00019 //-----------------------------------------------------------------------------
00020 class CAkLock
00021 {
00022 public:
00024     CAkLock() 
00025     {
00026 #ifdef AK_USE_METRO_API
00027         ::InitializeCriticalSectionEx( &m_csLock, 0, 0 );
00028 #else
00029         ::InitializeCriticalSection( &m_csLock );
00030 #endif
00031     }
00032 
00034     ~CAkLock()
00035     {
00036         ::DeleteCriticalSection( &m_csLock );
00037     }
00038 
00040     inline AKRESULT Lock( void )
00041     {
00042         ::EnterCriticalSection( &m_csLock );
00043         return AK_Success;
00044     }
00045 
00047     inline AKRESULT Unlock( void )
00048     {
00049         ::LeaveCriticalSection( &m_csLock );
00050         return AK_Success;
00051     }
00052 
00053 /*  // Returns AK_Success if lock aquired, AK_Fail otherwise.
00054     inline AKRESULT Trylock( void )
00055     {
00056         if ( ::TryEnterCriticalSection( &m_csLock ) )
00057             return AK_Success;
00058         return AK_Fail;
00059     } */
00060 
00061 private:
00062     CRITICAL_SECTION  m_csLock; 
00063 };
00064 
00065 #endif // _AKLOCK_H_

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise