aboutsummaryrefslogtreecommitdiffhomepage
path: root/common.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-05-13 20:19:02 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-05-13 20:19:02 -0700
commit129525af21d069943bb062e69a2a174e01a2c0e4 (patch)
tree012e32fbb55b3a13e211b0010066523f518c2546 /common.cpp
parentc15975113ab80241c71dc6dfa41a470b232de4ce (diff)
cd's special autosuggestion was broken, now fixed. Also, there's some tests for it now.
Diffstat (limited to 'common.cpp')
-rw-r--r--common.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/common.cpp b/common.cpp
index c283bc7a..787e9ed2 100644
--- a/common.cpp
+++ b/common.cpp
@@ -84,7 +84,9 @@ parts of fish.
struct termios shell_modes;
+// Note we foolishly assume that pthread_t is just a primitive. But it might be a struct.
static pthread_t main_thread_id = 0;
+static bool thread_assertions_configured_for_testing = false;
wchar_t ellipsis_char;
@@ -1926,6 +1928,10 @@ void set_main_thread() {
main_thread_id = pthread_self();
}
+void configure_thread_assertions_for_testing(void) {
+ thread_assertions_configured_for_testing = true;
+}
+
/* Notice when we've forked */
static pid_t initial_pid;
@@ -1950,7 +1956,7 @@ bool is_main_thread() {
void assert_is_main_thread(const char *who)
{
- if (! is_main_thread()) {
+ if (! is_main_thread() && ! thread_assertions_configured_for_testing) {
fprintf(stderr, "Warning: %s called off of main thread. Break on debug_thread_error to debug.\n", who);
debug_thread_error();
}
@@ -1966,7 +1972,7 @@ void assert_is_not_forked_child(const char *who)
void assert_is_background_thread(const char *who)
{
- if (is_main_thread()) {
+ if (is_main_thread() && ! thread_assertions_configured_for_testing) {
fprintf(stderr, "Warning: %s called on the main thread (may block!). Break on debug_thread_error to debug.\n", who);
debug_thread_error();
}