mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
show "transferred" attribute on Fiber#to_s
If a fiber is invoked with transfer method (such as "f.transfer"), then the invoked fiber ("f") is labeled as "transferred" and this fiber can not be invoked with Fiber#resume. This patch adds transferred attribute for "Fiber#to_s" (and inspect).
This commit is contained in:
parent
4c3e3b8028
commit
38e931fa2c
1 changed files with 10 additions and 4 deletions
14
cont.c
14
cont.c
|
@ -228,8 +228,8 @@ struct rb_fiber_struct {
|
|||
VALUE first_proc;
|
||||
struct rb_fiber_struct *prev;
|
||||
BITFIELD(enum fiber_status, status, 2);
|
||||
/* If a fiber invokes "transfer",
|
||||
* then this fiber can't "resume" any more after that.
|
||||
/* If a fiber invokes by "transfer",
|
||||
* then this fiber can't be invoked by "resume" any more after that.
|
||||
* You shouldn't mix "transfer" and "resume".
|
||||
*/
|
||||
unsigned int transferred : 1;
|
||||
|
@ -2273,9 +2273,15 @@ fiber_to_s(VALUE fiber_value)
|
|||
{
|
||||
const rb_fiber_t *fiber = fiber_ptr(fiber_value);
|
||||
const rb_proc_t *proc;
|
||||
char status_info[0x10];
|
||||
char status_info[0x20];
|
||||
|
||||
if (fiber->transferred) {
|
||||
snprintf(status_info, 0x20, " (%s, transferred)", fiber_status_name(fiber->status));
|
||||
}
|
||||
else {
|
||||
snprintf(status_info, 0x20, " (%s)", fiber_status_name(fiber->status));
|
||||
}
|
||||
|
||||
snprintf(status_info, 0x10, " (%s)", fiber_status_name(fiber->status));
|
||||
if (!rb_obj_is_proc(fiber->first_proc)) {
|
||||
VALUE str = rb_any_to_s(fiber_value);
|
||||
strlcat(status_info, ">", sizeof(status_info));
|
||||
|
|
Loading…
Add table
Reference in a new issue