diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-02-24 12:13:35 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-02-24 12:19:31 -0800 |
commit | a515db4aea51a032b06eb463fcc5a5b70066a18c (patch) | |
tree | 68774c3b9afbdadfbdde6ecdf8934b3099cdb331 /common.cpp | |
parent | 90e979d0d9a94601fc9a0c1e5ad785ede1e92381 (diff) |
Some work to allow completions to be evaluated off of the main thread
Diffstat (limited to 'common.cpp')
-rw-r--r-- | common.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -2070,5 +2070,15 @@ void assert_is_background_thread(const char *who) if (is_main_thread()) { fprintf(stderr, "Warning: %s called on the main thread (may block!). Break on debug_thread_error to debug.\n", who); debug_thread_error(); - } + } +} + +void assert_is_locked(void *vmutex, const char *who) +{ + pthread_mutex_t *mutex = static_cast<pthread_mutex_t*>(vmutex); + if (0 == pthread_mutex_trylock(mutex)) { + fprintf(stderr, "Warning: %s is not locked when it should be. Break on debug_thread_error to debug.\n", who); + debug_thread_error(); + pthread_mutex_unlock(mutex); + } } |