Skip to content

Commit f803bcf

Browse files
committed
pass th to thread_sched_to_waiting()
for future extension
1 parent 4c0f82e commit f803bcf

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

thread.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ static inline void blocking_region_end(rb_thread_t *th, struct rb_blocking_regio
174174
#define THREAD_BLOCKING_BEGIN(th) do { \
175175
struct rb_thread_sched * const sched = TH_SCHED(th); \
176176
RB_VM_SAVE_MACHINE_CONTEXT(th); \
177-
thread_sched_to_waiting(sched);
177+
thread_sched_to_waiting((sched), (th));
178178

179179
#define THREAD_BLOCKING_END(th) \
180-
thread_sched_to_running(sched, th); \
180+
thread_sched_to_running((sched), (th)); \
181181
rb_ractor_thread_switch(th->ractor, th); \
182182
} while(0)
183183

@@ -778,12 +778,12 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start)
778778
// after rb_ractor_living_threads_remove()
779779
// GC will happen anytime and this ractor can be collected (and destroy GVL).
780780
// So gvl_release() should be before it.
781-
thread_sched_to_dead(TH_SCHED(th));
781+
thread_sched_to_dead(TH_SCHED(th), th);
782782
rb_ractor_living_threads_remove(th->ractor, th);
783783
}
784784
else {
785785
rb_ractor_living_threads_remove(th->ractor, th);
786-
thread_sched_to_dead(TH_SCHED(th));
786+
thread_sched_to_dead(TH_SCHED(th), th);
787787
}
788788

789789
return 0;
@@ -1480,7 +1480,7 @@ blocking_region_begin(rb_thread_t *th, struct rb_blocking_region_buffer *region,
14801480
RUBY_DEBUG_LOG("");
14811481

14821482
RB_VM_SAVE_MACHINE_CONTEXT(th);
1483-
thread_sched_to_waiting(TH_SCHED(th));
1483+
thread_sched_to_waiting(TH_SCHED(th), th);
14841484
return TRUE;
14851485
}
14861486
else {

thread_none.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ thread_sched_to_running(struct rb_thread_sched *sched, rb_thread_t *th)
3030
}
3131

3232
static void
33-
thread_sched_to_waiting(struct rb_thread_sched *sched)
33+
thread_sched_to_waiting(struct rb_thread_sched *sched, rb_thread_t *th)
3434
{
3535
}
3636

thread_pthread.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ thread_sched_to_running(struct rb_thread_sched *sched, rb_thread_t *th)
521521
}
522522

523523
static rb_thread_t *
524-
thread_sched_to_waiting_common(struct rb_thread_sched *sched)
524+
thread_sched_to_waiting_common(struct rb_thread_sched *sched, rb_thread_t *th)
525525
{
526526
rb_thread_t *next;
527527
sched->running = NULL;
@@ -532,19 +532,19 @@ thread_sched_to_waiting_common(struct rb_thread_sched *sched)
532532
}
533533

534534
static void
535-
thread_sched_to_waiting(struct rb_thread_sched *sched)
535+
thread_sched_to_waiting(struct rb_thread_sched *sched, rb_thread_t *th)
536536
{
537537
RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_SUSPENDED);
538538
rb_native_mutex_lock(&sched->lock);
539-
thread_sched_to_waiting_common(sched);
539+
thread_sched_to_waiting_common(sched, th);
540540
rb_native_mutex_unlock(&sched->lock);
541541
}
542542

543543
static void
544-
thread_sched_to_dead(struct rb_thread_sched *sched)
544+
thread_sched_to_dead(struct rb_thread_sched *sched, rb_thread_t *th)
545545
{
546546
RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_EXITED);
547-
thread_sched_to_waiting(sched);
547+
thread_sched_to_waiting(sched, th);
548548
}
549549

550550
static void
@@ -558,7 +558,7 @@ thread_sched_yield(struct rb_thread_sched *sched, rb_thread_t *th)
558558
*/
559559
ubf_wakeup_all_threads();
560560
rb_native_mutex_lock(&sched->lock);
561-
next = thread_sched_to_waiting_common(sched);
561+
next = thread_sched_to_waiting_common(sched, th);
562562

563563
/* An another thread is processing GVL yield. */
564564
if (UNLIKELY(sched->wait_yield)) {
@@ -2209,7 +2209,7 @@ ubf_ppoll_sleep(void *ignore)
22092209
struct rb_thread_sched *sched = TH_SCHED(th); \
22102210
RB_VM_SAVE_MACHINE_CONTEXT(th); \
22112211
rb_native_mutex_lock(&sched->lock); \
2212-
next = thread_sched_to_waiting_common(sched); \
2212+
next = thread_sched_to_waiting_common((sched), (th)); \
22132213
rb_native_mutex_unlock(&sched->lock); \
22142214
if (!next && rb_ractor_living_thread_num(th->ractor) > 1) { \
22152215
native_thread_yield(); \

thread_win32.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ thread_sched_to_running(struct rb_thread_sched *sched, rb_thread_t *th)
134134
#define thread_sched_to_dead thread_sched_to_waiting
135135

136136
static void
137-
thread_sched_to_waiting(struct rb_thread_sched *sched)
137+
thread_sched_to_waiting(struct rb_thread_sched *sched, rb_thread_t *th)
138138
{
139139
ReleaseMutex(sched->lock);
140140
}
141141

142142
static void
143143
thread_sched_yield(struct rb_thread_sched *sched, rb_thread_t *th)
144144
{
145-
thread_sched_to_waiting(sched);
145+
thread_sched_to_waiting(sched, th);
146146
native_thread_yield();
147147
thread_sched_to_running(sched, th);
148148
}

0 commit comments

Comments
 (0)