зеркало из https://github.com/github/ruby.git
alen should be actions number on ractor_select()
alen was number of rs, but it should be actions number (taking ractors + receiving + yielding).
This commit is contained in:
Родитель
fb33ec0119
Коммит
d0d6227a0d
13
ractor.c
13
ractor.c
|
@ -1035,7 +1035,7 @@ ractor_try_yield(rb_execution_context_t *ec, rb_ractor_t *cr, struct rb_ractor_b
|
||||||
|
|
||||||
// select(r1, r2, r3, receive: true, yield: obj)
|
// select(r1, r2, r3, receive: true, yield: obj)
|
||||||
static VALUE
|
static VALUE
|
||||||
ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yielded_value, bool move, VALUE *ret_r)
|
ractor_select(rb_execution_context_t *ec, const VALUE *rs, const int rs_len, VALUE yielded_value, bool move, VALUE *ret_r)
|
||||||
{
|
{
|
||||||
rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
|
rb_ractor_t *cr = rb_ec_ractor_ptr(ec);
|
||||||
VALUE crv = cr->pub.self;
|
VALUE crv = cr->pub.self;
|
||||||
|
@ -1044,7 +1044,7 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield
|
||||||
bool interrupted = false;
|
bool interrupted = false;
|
||||||
enum ractor_wait_status wait_status = 0;
|
enum ractor_wait_status wait_status = 0;
|
||||||
bool yield_p = (yielded_value != Qundef) ? true : false;
|
bool yield_p = (yielded_value != Qundef) ? true : false;
|
||||||
const int rs_len = alen;
|
const int alen = rs_len + (yield_p ? 1 : 0);
|
||||||
|
|
||||||
struct ractor_select_action {
|
struct ractor_select_action {
|
||||||
enum ractor_select_action_type {
|
enum ractor_select_action_type {
|
||||||
|
@ -1053,7 +1053,7 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield
|
||||||
ractor_select_action_yield,
|
ractor_select_action_yield,
|
||||||
} type;
|
} type;
|
||||||
VALUE v;
|
VALUE v;
|
||||||
} *actions = ALLOCA_N(struct ractor_select_action, alen + (yield_p ? 1 : 0));
|
} *actions = ALLOCA_N(struct ractor_select_action, alen);
|
||||||
|
|
||||||
VM_ASSERT(cr->sync.wait.status == wait_none);
|
VM_ASSERT(cr->sync.wait.status == wait_none);
|
||||||
VM_ASSERT(cr->sync.wait.wakeup_status == wakeup_none);
|
VM_ASSERT(cr->sync.wait.wakeup_status == wakeup_none);
|
||||||
|
@ -1061,7 +1061,7 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield
|
||||||
VM_ASSERT(cr->sync.wait.yielded_basket.type == basket_type_none);
|
VM_ASSERT(cr->sync.wait.yielded_basket.type == basket_type_none);
|
||||||
|
|
||||||
// setup actions
|
// setup actions
|
||||||
for (i=0; i<alen; i++) {
|
for (i=0; i<rs_len; i++) {
|
||||||
VALUE v = rs[i];
|
VALUE v = rs[i];
|
||||||
|
|
||||||
if (v == crv) {
|
if (v == crv) {
|
||||||
|
@ -1080,17 +1080,16 @@ ractor_select(rb_execution_context_t *ec, const VALUE *rs, int alen, VALUE yield
|
||||||
}
|
}
|
||||||
rs = NULL;
|
rs = NULL;
|
||||||
|
|
||||||
restart:
|
|
||||||
|
|
||||||
if (yield_p) {
|
if (yield_p) {
|
||||||
actions[rs_len].type = ractor_select_action_yield;
|
actions[rs_len].type = ractor_select_action_yield;
|
||||||
actions[rs_len].v = Qundef;
|
actions[rs_len].v = Qundef;
|
||||||
wait_status |= wait_yielding;
|
wait_status |= wait_yielding;
|
||||||
alen++;
|
|
||||||
|
|
||||||
ractor_basket_setup(ec, &cr->sync.wait.yielded_basket, yielded_value, move, false, false);
|
ractor_basket_setup(ec, &cr->sync.wait.yielded_basket, yielded_value, move, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restart:
|
||||||
|
|
||||||
// TODO: shuffle actions
|
// TODO: shuffle actions
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче