*: Rename main loop variable from loop to main_loop

Current name is inappropriate for the following reasons:

1. It is often masked by local `loop` variables.
2. It cannot be searched for. There are many `loop` variables where `loop` is
   some local variable. There are many cases when “loop” word is used in
   a comment.
3. It is in any case bad idea to use a generic name as a name of the global
   variable. Best if global has module prefix: this is why it is in `main.h`:
   `main_loop` both stands for “a main loop” and “a loop defined in `main.*`”.

Since I have no idea how to list every occurrence of this variable method used
to rename it is “remove it from globals.h, try to compile, fix errors”. Thus if
some occurrence was hidden under false `#if` branch it was not replaced.
This commit is contained in:
ZyX
2016-05-30 20:55:29 +03:00
parent 748898b4dd
commit 77540a0458
19 changed files with 66 additions and 51 deletions

View File

@@ -67,6 +67,7 @@
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/ui.h"
#include "nvim/main.h"
#include "nvim/mouse.h"
#include "nvim/terminal.h"
#include "nvim/undo.h"
@@ -11812,7 +11813,7 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv)
list_T *rv = list_alloc();
ui_busy_start();
Queue *waiting_jobs = queue_new_parent(loop_on_put, &loop);
Queue *waiting_jobs = queue_new_parent(loop_on_put, &main_loop);
// For each item in the input list append an integer to the output list. -3
// is used to represent an invalid job id, -2 is for a interrupted job and
// -1 for jobs that were skipped or timed out.
@@ -11890,7 +11891,7 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv)
}
// restore the parent queue for the job
queue_process_events(data->events);
queue_replace_parent(data->events, loop.events);
queue_replace_parent(data->events, main_loop.events);
}
queue_free(waiting_jobs);
@@ -16534,8 +16535,8 @@ static void f_timer_start(typval_T *argvars, typval_T *rettv)
timer->timer_id = last_timer_id++;
timer->callback = func;
time_watcher_init(&loop, &timer->tw, timer);
timer->tw.events = queue_new_child(loop.events);
time_watcher_init(&main_loop, &timer->tw, timer);
timer->tw.events = queue_new_child(main_loop.events);
// if main loop is blocked, don't queue up multiple events
timer->tw.blockable = true;
time_watcher_start(&timer->tw, timer_due_cb, timeout,
@@ -21712,11 +21713,11 @@ static inline TerminalJobData *common_job_init(char **argv,
data->on_stderr = on_stderr;
data->on_exit = on_exit;
data->self = self;
data->events = queue_new_child(loop.events);
data->events = queue_new_child(main_loop.events);
if (pty) {
data->proc.pty = pty_process_init(&loop, data);
data->proc.pty = pty_process_init(&main_loop, data);
} else {
data->proc.uv = libuv_process_init(&loop, data);
data->proc.uv = libuv_process_init(&main_loop, data);
}
Process *proc = (Process *)&data->proc;
proc->argv = argv;
@@ -21814,7 +21815,7 @@ static inline void free_term_job_data(TerminalJobData *data)
{
// data->queue may still be used after this function returns(process_wait), so
// only free in the next event loop iteration
queue_put(loop.fast_events, free_term_job_data_event, 1, data);
queue_put(main_loop.fast_events, free_term_job_data_event, 1, data);
}
// vimscript job callbacks must be executed on Nvim main loop