Download raw body.
tog: todo item #2 respond to key presses while "loading..."
On Fri, Aug 12, 2022 at 11:36:46PM +0200, Stefan Sperling wrote: > Here is a case where movement doesn't seem to work while loading: > > tog log path > > Where path is any file in a deep history that has seen few changes. > The top-level Makefile in OpenBSD src.git is one such file. This can be fixed by... well, simply not waiting for the log thread. In hindsight, the articicial blocking behaviour was probably a bad idea. If we remove related code, the tog log view remains responsive at all times. ok? diff /home/stsp/src/got commit - 11edf34c28f6c60a1d37d5c83c758e90df02fe7a path + /home/stsp/src/got blob - fa53f96cb444650badb64394f0e1af4d9ea769f7 file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -340,7 +340,6 @@ static volatile sig_atomic_t tog_thread_error; struct tog_log_thread_args { pthread_cond_t need_commits; - pthread_cond_t commit_loaded; int commits_needed; int load_all; struct got_commit_graph *graph; @@ -2434,43 +2433,20 @@ log_scroll_up(struct tog_log_view_state *s, int maxscr } static const struct got_error * -trigger_log_thread(struct tog_view *view, int wait) +trigger_log_thread(struct tog_view *view) { struct tog_log_thread_args *ta = &view->state.log.thread_args; int errcode; halfdelay(1); /* fast refresh while loading commits */ - while (!ta->log_complete && !tog_thread_error && + if (!ta->log_complete && !tog_thread_error && (ta->commits_needed > 0 || ta->load_all)) { /* Wake the log thread. */ errcode = pthread_cond_signal(&ta->need_commits); if (errcode) return got_error_set_errno(errcode, "pthread_cond_signal"); - - /* - * The mutex will be released while the view loop waits - * in wgetch(), at which time the log thread will run. - */ - if (!wait) - break; - - /* Display progress update in log view. */ - show_log_view(view); - update_panels(); - doupdate(); - - /* Wait right here while next commit is being loaded. */ - errcode = pthread_cond_wait(&ta->commit_loaded, &tog_mutex); - if (errcode) - return got_error_set_errno(errcode, - "pthread_cond_wait"); - - /* Display progress update in log view. */ - show_log_view(view); - update_panels(); - doupdate(); } return NULL; @@ -2486,7 +2462,7 @@ request_log_commits(struct tog_view *view) return NULL; state->thread_args.commits_needed += view->nscrolled; - err = trigger_log_thread(view, 1); + err = trigger_log_thread(view); view->nscrolled = 0; return err; @@ -2511,7 +2487,7 @@ log_scroll_down(struct tog_view *view, int maxscroll) */ s->thread_args.commits_needed += ncommits_needed - s->commits.ncommits; - err = trigger_log_thread(view, 1); + err = trigger_log_thread(view); if (err) return err; } @@ -2766,14 +2742,6 @@ log_thread(void *arg) *a->selected_entry = *a->first_displayed_entry; } - errcode = pthread_cond_signal(&a->commit_loaded); - if (errcode) { - err = got_error_set_errno(errcode, - "pthread_cond_signal"); - pthread_mutex_unlock(&tog_mutex); - goto done; - } - if (done) a->commits_needed = 0; else { @@ -2798,7 +2766,6 @@ log_thread(void *arg) done: if (err) { tog_thread_error = 1; - pthread_cond_signal(&a->commit_loaded); } return (void *)err; } @@ -2863,10 +2830,6 @@ close_log_view(struct tog_view *view) if (errcode && err == NULL) err = got_error_set_errno(errcode, "pthread_cond_destroy"); - errcode = pthread_cond_destroy(&s->thread_args.commit_loaded); - if (errcode && err == NULL) - err = got_error_set_errno(errcode, "pthread_cond_destroy"); - free_commits(&s->commits); free(s->in_repo_path); s->in_repo_path = NULL; @@ -2963,7 +2926,7 @@ search_next_log_view(struct tog_view *view) * will resume at s->search_entry once we come back. */ s->thread_args.commits_needed++; - return trigger_log_thread(view, 0); + return trigger_log_thread(view); } err = match_commit(&have_match, entry->id, entry->commit, @@ -3091,11 +3054,6 @@ open_log_view(struct tog_view *view, struct got_object err = got_error_set_errno(errcode, "pthread_cond_init"); goto done; } - errcode = pthread_cond_init(&s->thread_args.commit_loaded, NULL); - if (errcode) { - err = got_error_set_errno(errcode, "pthread_cond_init"); - goto done; - } s->thread_args.commits_needed = view->nlines; s->thread_args.graph = thread_graph; @@ -3128,7 +3086,7 @@ show_log_view(struct tog_view *view) if (errcode) return got_error_set_errno(errcode, "pthread_create"); if (s->thread_args.commits_needed > 0) { - err = trigger_log_thread(view, 1); + err = trigger_log_thread(view); if (err) return err; } @@ -3384,7 +3342,7 @@ input_log_view(struct tog_view **new_view, struct tog_ view->count = 0; s->thread_args.load_all = 1; if (!s->thread_args.log_complete) - return trigger_log_thread(view, 0); + return trigger_log_thread(view); err = log_move_cursor_down(view, s->commits.ncommits); s->thread_args.load_all = 0; break; @@ -3409,7 +3367,7 @@ input_log_view(struct tog_view **new_view, struct tog_ !s->thread_args.log_complete) { s->thread_args.commits_needed += (view->nlines - 1) - s->commits.ncommits; - err = trigger_log_thread(view, 1); + err = trigger_log_thread(view); } break; case KEY_ENTER:
tog: todo item #2 respond to key presses while "loading..."