mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
add launcher
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
//#define KYTY_DEBUG_LOCKS
|
||||
|
||||
namespace Kyty::Core {
|
||||
|
||||
#ifdef THREADS_SDL
|
||||
@@ -65,7 +67,11 @@ struct Mutex::MutexPrivate
|
||||
#ifdef THREADS_SDL
|
||||
SDL_mutex* sdl;
|
||||
#else
|
||||
std::recursive_mutex m_mutex;
|
||||
#ifdef KYTY_DEBUG_LOCKS
|
||||
std::recursive_timed_mutex m_mutex;
|
||||
#else
|
||||
std::recursive_mutex m_mutex;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -212,9 +218,16 @@ void Mutex::Lock()
|
||||
{
|
||||
#ifdef THREADS_SDL
|
||||
SDL_LockMutex(m_mutex->sdl);
|
||||
#else
|
||||
#ifdef KYTY_DEBUG_LOCKS
|
||||
if (!m_mutex->m_mutex.try_lock_for(std::chrono::seconds(20)))
|
||||
{
|
||||
EXIT("lock timeout!");
|
||||
}
|
||||
#else
|
||||
m_mutex->m_mutex.lock();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void Mutex::Unlock()
|
||||
@@ -260,8 +273,12 @@ void CondVar::Wait(Mutex* mutex)
|
||||
{
|
||||
#ifdef THREADS_SDL
|
||||
SDL_CondWait(m_cond_var->sdl, mutex->m_mutex->sdl);
|
||||
#else
|
||||
#ifdef KYTY_DEBUG_LOCKS
|
||||
std::unique_lock<std::recursive_timed_mutex> cpp_lock(mutex->m_mutex->m_mutex, std::adopt_lock_t());
|
||||
#else
|
||||
std::unique_lock<std::recursive_mutex> cpp_lock(mutex->m_mutex->m_mutex, std::adopt_lock_t());
|
||||
#endif
|
||||
m_cond_var->m_cv.wait(cpp_lock);
|
||||
cpp_lock.release();
|
||||
#endif
|
||||
@@ -271,8 +288,12 @@ void CondVar::WaitFor(Mutex* mutex, uint32_t micros)
|
||||
{
|
||||
#ifdef THREADS_SDL
|
||||
SDL_CondWaitTimeout(m_cond_var->sdl, mutex->m_mutex->sdl, (micros < 1000 ? 1 : micros / 1000));
|
||||
#else
|
||||
#ifdef KYTY_DEBUG_LOCKS
|
||||
std::unique_lock<std::recursive_timed_mutex> cpp_lock(mutex->m_mutex->m_mutex, std::adopt_lock_t());
|
||||
#else
|
||||
std::unique_lock<std::recursive_mutex> cpp_lock(mutex->m_mutex->m_mutex, std::adopt_lock_t());
|
||||
#endif
|
||||
m_cond_var->m_cv.wait_for(cpp_lock, std::chrono::microseconds(micros));
|
||||
cpp_lock.release();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user