added qse_mtx_trylock() and QSE::Mutex::trylock()

This commit is contained in:
2018-08-16 03:45:17 +00:00
parent 0aca321aee
commit 73567527f1
8 changed files with 99 additions and 9 deletions

View File

@ -421,6 +421,9 @@
/* pthreads has pthread_mutex_timedlock() */
#undef HAVE_PTHREAD_MUTEX_TIMEDLOCK
/* pthreads has pthread_mutex_trylock() */
#undef HAVE_PTHREAD_MUTEX_TRYLOCK
/* Have PTHREAD_PRIO_INHERIT. */
#undef HAVE_PTHREAD_PRIO_INHERIT

View File

@ -47,12 +47,6 @@ public:
qse_mtx_fini (&this->mtx);
}
#if 0
bool tryock() QSE_CPP_NOEXCEPT
{
}
#endif
void lock () QSE_CPP_NOEXCEPT
{
qse_mtx_lock (&this->mtx, QSE_NULL);
@ -63,6 +57,11 @@ public:
qse_mtx_unlock (&this->mtx);
}
bool trylock () QSE_CPP_NOEXCEPT
{
return qse_mtx_trylock (&this->mtx) >= 0;
}
protected:
qse_mtx_t mtx;
};

View File

@ -127,6 +127,9 @@ QSE_EXPORT int qse_mtx_unlock (
qse_mtx_t* mtx
);
QSE_EXPORT int qse_mtx_trylock (
qse_mtx_t* mtx
);
#ifdef __cplusplus
}

View File

@ -172,7 +172,7 @@ protected:
int put_char (qse_char_t ch) QSE_CPP_NOEXCEPT
{
#if defined(QSE_CHAR_IS_MCHAR)
return this->put_mchar(ch)
return this->put_mchar(ch);
#else
return this->put_wchar(ch);
#endif