mirror of
https://github.com/ruby/ruby.git
synced 2026-10-29 00:46:26 +08:00
thead_sync.c: directly pass the execution context to yield
Saves one more call to GET_EC()
This commit is contained in:
1 parent
7e7a1db579
commit
ff831eb057
3 files changed
+19
-2
Notes:
git
2025-12-12 09:08:31 +00:00
No files matched your search
@@ -69,6 +69,7 @@ const char *rb_type_str(enum ruby_value_type type);
|
||||
VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
|
||||
VALUE rb_check_funcall_basic_kw(VALUE, ID, VALUE, int, const VALUE*, int);
|
||||
VALUE rb_yield_1(VALUE val);
|
||||
VALUE rb_ec_yield(struct rb_execution_context_struct *ec, VALUE val);
|
||||
VALUE rb_yield_force_blockarg(VALUE values);
|
||||
VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
|
||||
rb_block_call_func_t bl_proc, int min_argc, int max_argc,
|
||||
|
||||
+7
-2
@@ -650,7 +650,6 @@ rb_mutex_sleep(VALUE self, VALUE timeout)
|
||||
return rb_mut_sleep(GET_EC(), self, timeout);
|
||||
}
|
||||
|
||||
|
||||
VALUE
|
||||
rb_mutex_synchronize(VALUE self, VALUE (*func)(VALUE arg), VALUE arg)
|
||||
{
|
||||
@@ -660,6 +659,12 @@ rb_mutex_synchronize(VALUE self, VALUE (*func)(VALUE arg), VALUE arg)
|
||||
return rb_ec_ensure(args.ec, func, arg, do_mutex_unlock_safe, (VALUE)&args);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
do_ec_yield(VALUE _ec)
|
||||
{
|
||||
return rb_ec_yield((rb_execution_context_t *)_ec, Qundef);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_mut_synchronize(rb_execution_context_t *ec, VALUE self)
|
||||
{
|
||||
@@ -669,7 +674,7 @@ rb_mut_synchronize(rb_execution_context_t *ec, VALUE self)
|
||||
.ec = ec,
|
||||
};
|
||||
do_mutex_lock(&args, 1);
|
||||
return rb_ec_ensure(args.ec, rb_yield, Qundef, do_mutex_unlock_safe, (VALUE)&args);
|
||||
return rb_ec_ensure(args.ec, do_ec_yield, (VALUE)ec, do_mutex_unlock_safe, (VALUE)&args);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1379,6 +1379,17 @@ rb_yield(VALUE val)
|
||||
}
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_ec_yield(rb_execution_context_t *ec, VALUE val)
|
||||
{
|
||||
if (UNDEF_P(val)) {
|
||||
return vm_yield(ec, 0, NULL, RB_NO_KEYWORDS);
|
||||
}
|
||||
else {
|
||||
return vm_yield(ec, 1, &val, RB_NO_KEYWORDS);
|
||||
}
|
||||
}
|
||||
|
||||
#undef rb_yield_values
|
||||
VALUE
|
||||
rb_yield_values(int n, ...)
|
||||
|
||||
Reference in new issue
Block a user