1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #ifndef _AK_SYNC_CALLER_H_
- #define _AK_SYNC_CALLER_H_
- #include <AK/Tools/Common/AkPlatformFuncs.h>
- namespace AK
- {
- namespace SoundEngine
- {
-
-
- class AkSyncCaller
- {
- public:
- #if defined(AK_SUPPORT_THREADS)
-
- AKRESULT Init()
- {
- if ( AKPLATFORM::AkCreateEvent( m_hEvent ) != AK_Success )
- {
- AKASSERT( !"Could not create synchronization event" );
- return AK_Fail;
- }
- return AK_Success;
- }
-
- AKRESULT Wait( AKRESULT in_eResult )
- {
- if ( in_eResult != AK_Success )
- {
- AKPLATFORM::AkDestroyEvent( m_hEvent );
- return in_eResult;
- }
-
- AKPLATFORM::AkWaitForEvent( m_hEvent );
- AKPLATFORM::AkDestroyEvent( m_hEvent );
- return m_eResult;
- }
-
- inline void Done() { AKPLATFORM::AkSignalEvent( m_hEvent ); }
- #else
- AKRESULT Init() { m_bIsDone = false; return AK_Success;
- }
- inline bool IsDone() { return m_bIsDone; }
- inline void Done() { m_bIsDone = true; }
- #endif
- AKRESULT m_eResult;
- private:
- #if defined(AK_SUPPORT_THREADS)
- AkEvent m_hEvent;
- #else
- bool m_bIsDone;
- #endif
- };
- }
- }
- #endif
|