***/
void silc_mutex_unlock(SilcMutex mutex);
+/****f* silcutil/silc_mutex_trylock
+ *
+ * SYNOPSIS
+ *
+ * SilcBool silc_mutex_trylock(SilcMutex mutex);
+ *
+ * DESCRIPTION
+ *
+ * Attempts to lock the `mutex'. Returns TRUE if the caller was able
+ * to acquire the lock and FALSE if the mutex is already locked. If the
+ * mutex is already locked the caller cannot acquire the lock at this
+ * time.
+ *
+ ***/
+SilcBool silc_mutex_trylock(SilcMutex mutex);
+
/****f* silcutil/silc_mutex_assert_locked
*
* SYNOPSIS
#endif /* SILC_THREADS */
}
+SilcBool silc_mutex_trylock(SilcMutex mutex)
+{
+#ifdef SILC_THREADS
+ if (mutex) {
+ if (pthread_mutex_trylock(&mutex->mutex) == 0) {
+ mutex->locked = TRUE;
+ return TRUE;
+ }
+ }
+#endif /* SILC_THREADS */
+ return FALSE;
+}
+
void silc_mutex_assert_locked(SilcMutex mutex)
{
#ifdef SILC_THREADS