aboutsummaryrefslogtreecommitdiffhomepage
path: root/common.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-24 12:13:35 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-24 12:19:31 -0800
commita515db4aea51a032b06eb463fcc5a5b70066a18c (patch)
tree68774c3b9afbdadfbdde6ecdf8934b3099cdb331 /common.cpp
parent90e979d0d9a94601fc9a0c1e5ad785ede1e92381 (diff)
Some work to allow completions to be evaluated off of the main thread
Diffstat (limited to 'common.cpp')
-rw-r--r--common.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/common.cpp b/common.cpp
index 13d08512..d8f76ab5 100644
--- a/common.cpp
+++ b/common.cpp
@@ -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);
+ }
}