Skip to content

Commit

Permalink
refactoring rb_ractor_confirm_belonging()
Browse files Browse the repository at this point in the history
rb_ractor_belonging() returns 0 only if it has sharable flag.
rb_ractor_confirm_belonging() checks rb_ractor_shareable_p()
if the belonging ractor id is different from current ractor id.
  • Loading branch information
ko1 committed Oct 21, 2020
1 parent 631eaa8 commit af24713
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ractor.h
Expand Up @@ -257,7 +257,7 @@ rb_ractor_setup_belonging(VALUE obj)
static inline uint32_t
rb_ractor_belonging(VALUE obj)
{
if (rb_ractor_shareable_p(obj)) {
if (SPECIAL_CONST_P(obj) || RB_OBJ_SHAREABLE_P(obj)) {
return 0;
}
else {
Expand All @@ -277,8 +277,13 @@ rb_ractor_confirm_belonging(VALUE obj)
}
}
else if (UNLIKELY(id != rb_ractor_current_id())) {
rp(obj);
rb_bug("rb_ractor_confirm_belonging object-ractor id:%u, current-ractor id:%u", id, rb_ractor_current_id());
if (rb_ractor_shareable_p(obj)) {
// ok
}
else {
rp(obj);
rb_bug("rb_ractor_confirm_belonging object-ractor id:%u, current-ractor id:%u", id, rb_ractor_current_id());
}
}
return obj;
}
Expand Down

0 comments on commit af24713

Please sign in to comment.