Skip to content

Commit 909d6b8

Browse files
author
Jacob Lacouture
committed
share the deferred_wait thread at process level
1 parent 2b70d8c commit 909d6b8

File tree

9 files changed

+205
-94
lines changed

9 files changed

+205
-94
lines changed

ccan/list/list.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,26 @@ static inline void ccan_list_add_tail_(struct ccan_list_head *h,
200200
ccan_list_add_before_(h, &h->n, n, abortstr);
201201
}
202202

203+
/**
204+
* ccan_node_linked - is a node embedded in any list?
205+
* @n: the ccan_list_node
206+
*
207+
* Returns false if the node belongs to any list.
208+
* We tolerate two "unlinked" states. One created by ccan_list_node_init
209+
* and one where the pointers are set to NULL, as by ccan_list_del when
210+
* CCAN_LIST_DEBUG is enabled.
211+
*
212+
* Example:
213+
* ccan_list_del(&child->list);
214+
* assert(!ccan_node_linked(&child->list));
215+
*/
216+
#define ccan_node_linked(n) ccan_node_linked_(n, CCAN_LIST_LOC)
217+
static inline int ccan_node_linked_(const struct ccan_list_node *n, const char* abortstr)
218+
{
219+
(void)ccan_list_debug_node(n, abortstr);
220+
return n != n->next && n->next;
221+
}
222+
203223
/**
204224
* ccan_list_empty - is a list empty?
205225
* @h: the ccan_list_head

eval.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ rb_ec_cleanup(rb_execution_context_t *ec, enum ruby_tag_type ex)
262262
EC_POP_TAG();
263263
th = th0;
264264
rb_thread_stop_timer_thread();
265+
rb_thread_stop_deferred_wait_thread(false);
265266
ruby_vm_destruct(th->vm);
266267
// For YJIT, call this after ruby_vm_destruct() frees jit_cont for the root fiber.
267268
rb_jit_cont_finish();

process.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,7 @@ before_exec_non_async_signal_safe(void)
15221522
* Nowadays, we always stop the timer thread completely to allow redirects.
15231523
*/
15241524
rb_thread_stop_timer_thread();
1525+
rb_thread_stop_deferred_wait_thread(false);
15251526
}
15261527

15271528
#define WRITE_CONST(fd, str) (void)(write((fd),(str),sizeof(str)-1)<0)
@@ -1569,6 +1570,7 @@ after_exec(void)
15691570
{
15701571
rb_thread_reset_timer_thread();
15711572
rb_thread_start_timer_thread();
1573+
rb_thread_start_deferred_wait_thread(false);
15721574
}
15731575

15741576
#if defined HAVE_WORKING_FORK || defined HAVE_DAEMON

thread.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5761,6 +5761,7 @@ Init_Thread(void)
57615761
}
57625762

57635763
rb_thread_create_timer_thread();
5764+
rb_thread_start_deferred_wait_thread(true);
57645765

57655766
Init_thread_sync();
57665767

thread_none.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ thread_sched_blocking_region_exit(struct rb_thread_sched *sched, rb_thread_t *th
4747
{
4848
}
4949

50+
void
51+
rb_thread_start_deferred_wait_thread(bool init)
52+
{
53+
}
54+
55+
void
56+
rb_thread_stop_deferred_wait_thread(bool destroy)
57+
{
58+
}
59+
5060
void
5161
rb_thread_sched_init(struct rb_thread_sched *sched, bool atfork)
5262
{

0 commit comments

Comments
 (0)