mjit.c: unify wording between comments and variables

Some comments say "stop", others say "finish".

I'm going to add code which dynamically stops MJIT worker, rather than
finishing it forever. So I'm thinking `stop` is more appropreate for it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-06-06 14:36:56 +00:00
parent c995315153
commit 0dc5068892

28
mjit.c
View File

@ -913,10 +913,10 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
return (mjit_func_t)func; return (mjit_func_t)func;
} }
/* Set to TRUE to finish worker. */ /* Set to TRUE to stop worker. */
static int finish_worker_p; static int stop_worker_p;
/* Set to TRUE if worker is finished. */ /* Set to TRUE if worker is stopped. */
static int worker_finished; static int worker_stopped;
/* The function implementing a worker. It is executed in a separate /* The function implementing a worker. It is executed in a separate
thread by rb_thread_create_mjit_thread. It compiles precompiled header thread by rb_thread_create_mjit_thread. It compiles precompiled header
@ -927,21 +927,21 @@ worker(void)
make_pch(); make_pch();
if (pch_status == PCH_FAILED) { if (pch_status == PCH_FAILED) {
mjit_init_p = FALSE; mjit_init_p = FALSE;
CRITICAL_SECTION_START(3, "in worker to update worker_finished"); CRITICAL_SECTION_START(3, "in worker to update worker_stopped");
worker_finished = TRUE; worker_stopped = TRUE;
verbose(3, "Sending wakeup signal to client in a mjit-worker"); verbose(3, "Sending wakeup signal to client in a mjit-worker");
rb_native_cond_signal(&mjit_client_wakeup); rb_native_cond_signal(&mjit_client_wakeup);
CRITICAL_SECTION_FINISH(3, "in worker to update worker_finished"); CRITICAL_SECTION_FINISH(3, "in worker to update worker_stopped");
return; /* TODO: do the same thing in the latter half of mjit_finish */ return; /* TODO: do the same thing in the latter half of mjit_finish */
} }
/* main worker loop */ /* main worker loop */
while (!finish_worker_p) { while (!stop_worker_p) {
struct rb_mjit_unit_node *node; struct rb_mjit_unit_node *node;
/* wait until unit is available */ /* wait until unit is available */
CRITICAL_SECTION_START(3, "in worker dequeue"); CRITICAL_SECTION_START(3, "in worker dequeue");
while ((unit_queue.head == NULL || active_units.length > mjit_opts.max_cache_size) && !finish_worker_p) { while ((unit_queue.head == NULL || active_units.length > mjit_opts.max_cache_size) && !stop_worker_p) {
rb_native_cond_wait(&mjit_worker_wakeup, &mjit_engine_mutex); rb_native_cond_wait(&mjit_worker_wakeup, &mjit_engine_mutex);
verbose(3, "Getting wakeup from client"); verbose(3, "Getting wakeup from client");
} }
@ -962,7 +962,7 @@ worker(void)
} }
/* To keep mutex unlocked when it is destroyed by mjit_finish, don't wrap CRITICAL_SECTION here. */ /* To keep mutex unlocked when it is destroyed by mjit_finish, don't wrap CRITICAL_SECTION here. */
worker_finished = TRUE; worker_stopped = TRUE;
} }
/* MJIT info related to an existing continutaion. */ /* MJIT info related to an existing continutaion. */
@ -1421,8 +1421,8 @@ mjit_init(struct mjit_options *opts)
rb_define_global_const("RUBY_DESCRIPTION", rb_obj_freeze(rb_description)); rb_define_global_const("RUBY_DESCRIPTION", rb_obj_freeze(rb_description));
/* Initialize worker thread */ /* Initialize worker thread */
finish_worker_p = FALSE; stop_worker_p = FALSE;
worker_finished = FALSE; worker_stopped = FALSE;
if (!rb_thread_create_mjit_thread(child_after_fork, worker)) { if (!rb_thread_create_mjit_thread(child_after_fork, worker)) {
mjit_init_p = FALSE; mjit_init_p = FALSE;
rb_native_mutex_destroy(&mjit_engine_mutex); rb_native_mutex_destroy(&mjit_engine_mutex);
@ -1458,8 +1458,8 @@ mjit_finish(void)
CRITICAL_SECTION_FINISH(3, "in mjit_finish to wakeup from pch"); CRITICAL_SECTION_FINISH(3, "in mjit_finish to wakeup from pch");
/* Stop worker */ /* Stop worker */
finish_worker_p = TRUE; stop_worker_p = TRUE;
while (!worker_finished) { while (!worker_stopped) {
verbose(3, "Sending cancel signal to workers"); verbose(3, "Sending cancel signal to workers");
CRITICAL_SECTION_START(3, "in mjit_finish"); CRITICAL_SECTION_START(3, "in mjit_finish");
rb_native_cond_broadcast(&mjit_worker_wakeup); rb_native_cond_broadcast(&mjit_worker_wakeup);