Remove unnecessary pthread_yield(3). In the two cases a context switch isn't necessary as the thread isn't blocked and doesn't need to wait for its sibling.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/tog/tog.c b/tog/tog.c
index ac26de5..0e878ef 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -747,15 +747,6 @@ view_input(struct tog_view **new, struct tog_view **dead,
*focus = NULL;
if (view->searching && !view->search_next_done) {
- errcode = pthread_mutex_unlock(&tog_mutex);
- if (errcode)
- return got_error_set_errno(errcode,
- "pthread_mutex_unlock");
- pthread_yield();
- errcode = pthread_mutex_lock(&tog_mutex);
- if (errcode)
- return got_error_set_errno(errcode,
- "pthread_mutex_lock");
view->search_next(view);
return NULL;
}
@@ -1638,16 +1629,6 @@ trigger_log_thread(int load_all, int *commits_needed, int *log_complete,
if (errcode)
return got_error_set_errno(errcode,
"pthread_cond_signal");
- errcode = pthread_mutex_unlock(&tog_mutex);
- if (errcode)
- return got_error_set_errno(errcode,
- "pthread_mutex_unlock");
- pthread_yield();
- errcode = pthread_mutex_lock(&tog_mutex);
- if (errcode)
- return got_error_set_errno(errcode,
- "pthread_mutex_lock");
-
if (*commits_needed > 0 && (!load_all || --max_wait <= 0)) {
/*
* Thread is not done yet; lose a key press