cont.c File Reference

#include "ruby/ruby.h"
#include "internal.h"
#include "vm_core.h"
#include "gc.h"
#include "eval_intern.h"

Go to the source code of this file.

Data Structures

struct  rb_context_struct
struct  rb_fiber_struct

Defines

#define FIBER_USE_NATIVE   0
#define CAPTURE_JUST_VALID_VM_STACK   1
#define GetContPtr(obj, ptr)   TypedData_Get_Struct((obj), rb_context_t, &cont_data_type, (ptr))
#define GetFiberPtr(obj, ptr)
#define THREAD_MUST_BE_RUNNING(th)
#define STACK_PAD_SIZE   1024

Typedefs

typedef rb_context_struct rb_context_t
typedef rb_fiber_struct rb_fiber_t

Enumerations

enum  context_type { CONTINUATION_CONTEXT = 0, FIBER_CONTEXT = 1, ROOT_FIBER_CONTEXT = 2 }
enum  fiber_status { CREATED, RUNNING, TERMINATED }

Functions

 NOINLINE (static VALUE cont_capture(volatile int *stat))
static void cont_mark (void *ptr)
static void cont_free (void *ptr)
static size_t cont_memsize (const void *ptr)
static void fiber_mark (void *ptr)
static void fiber_link_join (rb_fiber_t *fib)
static void fiber_link_remove (rb_fiber_t *fib)
static void fiber_free (void *ptr)
static size_t fiber_memsize (const void *ptr)
VALUE rb_obj_is_fiber (VALUE obj)
static void cont_save_machine_stack (rb_thread_t *th, rb_context_t *cont)
static void cont_save_thread (rb_context_t *cont, rb_thread_t *th)
static void cont_init (rb_context_t *cont, rb_thread_t *th)
static rb_context_tcont_new (VALUE klass)
static VALUE cont_capture (volatile int *stat)
static void cont_restore_thread (rb_context_t *cont)
 NOINLINE (NORETURN(static void cont_restore_1(rb_context_t *)))
static void cont_restore_1 (rb_context_t *cont)
 NORETURN (NOINLINE(static void cont_restore_0(rb_context_t *, VALUE *)))
static void cont_restore_0 (rb_context_t *cont, VALUE *addr_in_prev_frame)
static VALUE rb_callcc (VALUE self)
static VALUE make_passing_arg (int argc, VALUE *argv)
void ruby_register_rollback_func_for_ensure (VALUE(*ensure_func)(ANYARGS), VALUE(*rollback_func)(ANYARGS))
static VALUE lookup_rollback_func (VALUE(*ensure_func)(ANYARGS))
static void rollback_ensure_stack (VALUE self, rb_ensure_list_t *current, rb_ensure_entry_t *target)
static VALUE rb_cont_call (int argc, VALUE *argv, VALUE contval)
static VALUE fiber_alloc (VALUE klass)
static rb_fiber_tfiber_t_alloc (VALUE fibval)
static VALUE fiber_init (VALUE fibval, VALUE proc)
static VALUE rb_fiber_init (VALUE fibval)
VALUE rb_fiber_new (VALUE(*func)(ANYARGS), VALUE obj)
static VALUE return_fiber (void)
VALUE rb_fiber_transfer (VALUE fib, int argc, VALUE *argv)
static void rb_fiber_terminate (rb_fiber_t *fib)
void rb_fiber_start (void)
static rb_fiber_troot_fiber_alloc (rb_thread_t *th)
VALUE rb_fiber_current (void)
static VALUE fiber_store (rb_fiber_t *next_fib)
static VALUE fiber_switch (VALUE fibval, int argc, VALUE *argv, int is_resume)
VALUE rb_fiber_resume (VALUE fibval, int argc, VALUE *argv)
VALUE rb_fiber_yield (int argc, VALUE *argv)
void rb_fiber_reset_root_local_storage (VALUE thval)
VALUE rb_fiber_alive_p (VALUE fibval)
static VALUE rb_fiber_m_resume (int argc, VALUE *argv, VALUE fib)
static VALUE rb_fiber_m_transfer (int argc, VALUE *argv, VALUE fibval)
static VALUE rb_fiber_s_yield (int argc, VALUE *argv, VALUE klass)
static VALUE rb_fiber_s_current (VALUE klass)
void Init_Cont (void)
RUBY_SYMBOL_EXPORT_BEGIN void ruby_Init_Continuation_body (void)
void ruby_Init_Fiber_as_Coroutine (void)

Variables

static const rb_data_type_t cont_data_type
static const rb_data_type_t fiber_data_type
static VALUE rb_cContinuation
static VALUE rb_cFiber
static VALUE rb_eFiberError
static const rb_data_type_t cont_data_type
static const rb_data_type_t fiber_data_type


Define Documentation

#define CAPTURE_JUST_VALID_VM_STACK   1

Definition at line 82 of file cont.c.

#define FIBER_USE_NATIVE   0

Definition at line 68 of file cont.c.

Referenced by fiber_store().

#define GetContPtr ( obj,
ptr   )     TypedData_Get_Struct((obj), rb_context_t, &cont_data_type, (ptr))

Definition at line 159 of file cont.c.

Referenced by rb_cont_call().

#define GetFiberPtr ( obj,
ptr   ) 

Value:

do {\
    TypedData_Get_Struct((obj), rb_fiber_t, &fiber_data_type, (ptr)); \
    if (!(ptr)) rb_raise(rb_eFiberError, "uninitialized fiber"); \
} while (0)

Definition at line 162 of file cont.c.

Referenced by cont_restore_thread(), fiber_link_join(), fiber_store(), fiber_switch(), rb_cont_call(), rb_fiber_alive_p(), rb_fiber_m_transfer(), rb_fiber_reset_root_local_storage(), rb_fiber_resume(), rb_fiber_start(), and return_fiber().

#define STACK_PAD_SIZE   1024

Referenced by cont_restore_0().

#define THREAD_MUST_BE_RUNNING ( th   ) 

Value:

do { \
        if (!(th)->tag) rb_raise(rb_eThreadError, "not running thread");        \
    } while (0)

Definition at line 169 of file cont.c.

Referenced by cont_capture(), cont_new(), and fiber_t_alloc().


Typedef Documentation

typedef struct rb_context_struct rb_context_t

typedef struct rb_fiber_struct rb_fiber_t


Enumeration Type Documentation

enum context_type

Enumerator:
CONTINUATION_CONTEXT 
FIBER_CONTEXT 
ROOT_FIBER_CONTEXT 

Definition at line 84 of file cont.c.

enum fiber_status

Enumerator:
CREATED 
RUNNING 
TERMINATED 

Definition at line 116 of file cont.c.


Function Documentation

static VALUE cont_capture ( volatile int *  stat  )  [static]

Definition at line 468 of file cont.c.

References ALLOC_N, rb_context_struct::argc, rb_thread_struct::cfp, rb_fiber_struct::cont, cont_new(), cont_save_machine_stack(), rb_context_struct::ensure_array, rb_thread_struct::ensure_list, rb_ensure_list::entry, GET_THREAD(), rb_context_struct::jmpbuf, rb_thread_struct::mark_stack_len, rb_ensure_entry::marker, MEMCPY, rb_ensure_list::next, Qnil, rb_ary_tmp_new(), rb_cContinuation, rb_exc_raise(), rb_vm_stack_to_heap(), ruby_setjmp, rb_context_struct::saved_thread, rb_context_struct::self, size, rb_control_frame_struct::sp, rb_thread_struct::stack, rb_thread_struct::stack_size, THREAD_MUST_BE_RUNNING, rb_context_struct::value, VALUE, rb_context_struct::vm_stack, rb_context_struct::vm_stack_clen, and rb_context_struct::vm_stack_slen.

Referenced by rb_callcc().

static void cont_free ( void *  ptr  )  [static]

Definition at line 221 of file cont.c.

References rb_fiber_struct::cont, CONTINUATION_CONTEXT, rb_context_struct::ensure_array, GET_THREAD(), rb_context_struct::machine, rb_bug(), ROOT_FIBER_CONTEXT, RUBY_FREE_ENTER, RUBY_FREE_LEAVE, RUBY_FREE_UNLESS_NULL, ruby_xfree(), rb_context_struct::saved_thread, rb_context_struct::self, rb_context_struct::stack, rb_thread_struct::stack, rb_context_struct::type, and rb_context_struct::vm_stack.

Referenced by fiber_free().

static void cont_init ( rb_context_t cont,
rb_thread_t th 
) [static]

Definition at line 446 of file cont.c.

References rb_fiber_struct::cont, cont_save_thread(), rb_thread_struct::local_storage, and rb_context_struct::saved_thread.

Referenced by cont_new(), and fiber_t_alloc().

static void cont_mark ( void *  ptr  )  [static]

Definition at line 174 of file cont.c.

References rb_fiber_struct::cont, CONTINUATION_CONTEXT, rb_thread_struct::fiber, GetThreadPtr, rb_context_struct::machine, rb_gc_mark(), rb_gc_mark_locations, rb_thread_mark(), RUBY_MARK_ENTER, RUBY_MARK_LEAVE, RUNNING, rb_context_struct::saved_thread, rb_context_struct::self, rb_thread_struct::self, rb_context_struct::stack, rb_context_struct::stack_size, rb_thread_struct::stack_size, rb_fiber_struct::status, rb_context_struct::type, rb_context_struct::value, rb_context_struct::vm_stack, rb_context_struct::vm_stack_clen, and rb_context_struct::vm_stack_slen.

Referenced by fiber_mark().

static size_t cont_memsize ( const void *  ptr  )  [static]

Definition at line 276 of file cont.c.

References rb_fiber_struct::cont, rb_context_struct::machine, rb_context_struct::saved_thread, size, rb_context_struct::stack, rb_context_struct::stack_size, rb_thread_struct::stack_size, rb_context_struct::vm_stack, rb_context_struct::vm_stack_clen, and rb_context_struct::vm_stack_slen.

Referenced by fiber_memsize().

static rb_context_t* cont_new ( VALUE  klass  )  [static]

Definition at line 454 of file cont.c.

References rb_fiber_struct::cont, cont_data_type, cont_init(), GET_THREAD(), rb_context_struct::self, THREAD_MUST_BE_RUNNING, TypedData_Make_Struct, and VALUE.

Referenced by cont_capture().

static void cont_restore_0 ( rb_context_t cont,
VALUE *  addr_in_prev_frame 
) [static]

Definition at line 801 of file cont.c.

References ALLOCA_N, rb_fiber_struct::cont, cont_restore_1(), rb_context_struct::machine, STACK_PAD_SIZE, rb_context_struct::stack_size, rb_context_struct::stack_src, and VALUE.

Referenced by fiber_switch(), and rb_cont_call().

static void cont_restore_1 ( rb_context_t cont  )  [static]

Definition at line 733 of file cont.c.

References buf, rb_fiber_struct::cont, cont_restore_thread(), FLUSH_REGISTER_WINDOWS, rb_context_struct::jmpbuf, rb_context_struct::machine, MEMCPY, ruby_longjmp, rb_context_struct::stack, rb_context_struct::stack_size, rb_context_struct::stack_src, and VALUE.

Referenced by cont_restore_0().

static void cont_restore_thread ( rb_context_t cont  )  [static]

Definition at line 526 of file cont.c.

References rb_thread_struct::cfp, rb_fiber_struct::cont, CONTINUATION_CONTEXT, rb_thread_struct::ensure_list, rb_thread_struct::errinfo, rb_thread_struct::fiber, rb_thread_struct::first_proc, GET_THREAD(), GetFiberPtr, rb_thread_struct::local_storage, MEMCPY, rb_thread_struct::protect_tag, rb_thread_struct::raised_flag, rb_thread_struct::root_fiber, rb_thread_struct::root_lep, rb_thread_struct::root_svar, rb_thread_struct::safe_level, rb_context_struct::saved_thread, rb_context_struct::self, rb_thread_struct::stack, rb_thread_struct::stack_size, rb_thread_struct::state, rb_thread_struct::status, rb_vm_tag::tag, rb_thread_struct::tag, rb_context_struct::type, VALUE, rb_context_struct::vm_stack, rb_context_struct::vm_stack_clen, and rb_context_struct::vm_stack_slen.

Referenced by cont_restore_1().

static void cont_save_machine_stack ( rb_thread_t th,
rb_context_t cont 
) [static]

Definition at line 381 of file cont.c.

References ALLOC_N, rb_fiber_struct::cont, FLUSH_REGISTER_WINDOWS, rb_context_struct::machine, rb_thread_struct::machine, MEMCPY, REALLOC_N, SET_MACHINE_STACK_END, size, rb_context_struct::stack, rb_thread_struct::stack_end, rb_context_struct::stack_size, rb_context_struct::stack_src, rb_thread_struct::stack_start, and VALUE.

Referenced by cont_capture(), and fiber_store().

static void cont_save_thread ( rb_context_t cont,
rb_thread_t th 
) [static]

Definition at line 431 of file cont.c.

References rb_fiber_struct::cont, rb_thread_struct::machine, rb_context_struct::saved_thread, rb_thread_struct::stack_end, and rb_thread_struct::stack_start.

Referenced by cont_init(), and fiber_store().

static VALUE fiber_alloc ( VALUE  klass  )  [static]

Definition at line 1140 of file cont.c.

References fiber_data_type, and TypedData_Wrap_Struct.

Referenced by Init_Cont(), rb_fiber_new(), and root_fiber_alloc().

static void fiber_free ( void *  ptr  )  [static]

Definition at line 337 of file cont.c.

References rb_fiber_struct::cont, cont_free(), fiber_link_remove(), rb_thread_struct::local_storage, ROOT_FIBER_CONTEXT, RUBY_FREE_ENTER, RUBY_FREE_LEAVE, rb_context_struct::saved_thread, st_free_table(), and rb_context_struct::type.

static VALUE fiber_init ( VALUE  fibval,
VALUE  proc 
) [static]

Definition at line 1170 of file cont.c.

References ALLOC_N, rb_control_frame_struct::block_iseq, rb_thread_struct::cfp, rb_fiber_struct::cont, rb_vm_struct::default_params, rb_control_frame_struct::ep, fiber_link_join(), fiber_t_alloc(), rb_vm_struct::fiber_vm_stack_size, rb_thread_struct::first_proc, rb_control_frame_struct::flag, rb_control_frame_struct::iseq, rb_context_struct::jmpbuf, rb_control_frame_struct::klass, rb_thread_struct::local_storage, rb_control_frame_struct::me, MEMCPY, rb_control_frame_struct::pc, rb_control_frame_struct::proc, Qnil, rb_thread_struct::root_jmpbuf, rb_context_struct::saved_thread, rb_control_frame_struct::self, rb_control_frame_struct::sp, st_init_numtable(), rb_thread_struct::stack, rb_thread_struct::stack_size, rb_thread_struct::tag, VALUE, rb_thread_struct::vm, VM_ENVVAL_BLOCK_PTR, and rb_context_struct::vm_stack.

Referenced by rb_fiber_init(), and rb_fiber_new().

static void fiber_link_join ( rb_fiber_t fib  )  [static]

Definition at line 316 of file cont.c.

References GetFiberPtr, rb_fiber_struct::next_fiber, rb_fiber_struct::prev_fiber, rb_fiber_current(), and VALUE.

Referenced by fiber_init().

static void fiber_link_remove ( rb_fiber_t fib  )  [static]

Definition at line 330 of file cont.c.

References rb_fiber_struct::next_fiber, and rb_fiber_struct::prev_fiber.

Referenced by fiber_free().

static void fiber_mark ( void *  ptr  )  [static]

Definition at line 304 of file cont.c.

References rb_fiber_struct::cont, cont_mark(), rb_fiber_struct::prev, rb_gc_mark(), RUBY_MARK_ENTER, and RUBY_MARK_LEAVE.

static size_t fiber_memsize ( const void *  ptr  )  [static]

Definition at line 354 of file cont.c.

References rb_fiber_struct::cont, cont_memsize(), rb_thread_struct::local_storage, NULL, ROOT_FIBER_CONTEXT, rb_context_struct::saved_thread, size, st_memsize(), and rb_context_struct::type.

static VALUE fiber_store ( rb_fiber_t next_fib  )  [static]

Definition at line 1344 of file cont.c.

References rb_context_struct::argc, rb_fiber_struct::cont, cont_save_machine_stack(), cont_save_thread(), rb_thread_struct::fiber, FIBER_USE_NATIVE, GET_THREAD(), GetFiberPtr, rb_context_struct::jmpbuf, rb_context_struct::machine, NULL, Qundef, rb_bug(), rb_exc_raise(), rb_thread_struct::root_fiber, root_fiber_alloc(), ruby_setjmp, rb_context_struct::self, rb_context_struct::stack, rb_context_struct::value, and VALUE.

Referenced by fiber_switch().

static VALUE fiber_switch ( VALUE  fibval,
int  argc,
VALUE *  argv,
int  is_resume 
) [inline, static]

Definition at line 1399 of file cont.c.

References rb_context_struct::argc, rb_fiber_struct::cont, cont_restore_0(), rb_thread_struct::fiber, fiber_store(), GET_THREAD(), GetFiberPtr, make_passing_arg(), NIL_P, rb_fiber_struct::prev, rb_thread_struct::protect_tag, Qundef, rb_bug(), rb_eFiberError, rb_exc_new2, rb_exc_raise(), rb_fiber_current(), rb_raise(), rb_thread_struct::root_fiber, RUBY_VM_CHECK_INTS, rb_context_struct::saved_thread, rb_thread_struct::self, rb_fiber_struct::status, TERMINATED, rb_thread_struct::trace_arg, rb_context_struct::value, and VALUE.

Referenced by rb_fiber_resume(), and rb_fiber_transfer().

static rb_fiber_t* fiber_t_alloc ( VALUE  fibval  )  [static]

Definition at line 1146 of file cont.c.

References ALLOC, rb_fiber_struct::cont, cont_init(), CREATED, DATA_PTR, FIBER_CONTEXT, GET_THREAD(), rb_fiber_struct::prev, Qnil, rb_eRuntimeError, rb_raise(), rb_context_struct::self, rb_fiber_struct::status, THREAD_MUST_BE_RUNNING, and rb_context_struct::type.

Referenced by fiber_init(), and root_fiber_alloc().

void Init_Cont ( void   ) 

Definition at line 1652 of file cont.c.

References fiber_alloc(), GET_THREAD(), rb_thread_struct::machine, rb_cFiber, rb_cObject, rb_define_alloc_func(), rb_define_class(), rb_define_method(), rb_define_singleton_method(), rb_eFiberError, rb_eStandardError, rb_fiber_init(), rb_fiber_m_resume(), rb_fiber_s_yield(), SET_MACHINE_STACK_END, and rb_thread_struct::stack_end.

static VALUE lookup_rollback_func ( VALUE(*)(ANYARGS)  ensure_func  )  [inline, static]

Definition at line 957 of file cont.c.

References GET_VM, Qundef, st_data_t, st_lookup(), val, and VALUE.

Referenced by rollback_ensure_stack().

static VALUE make_passing_arg ( int  argc,
VALUE *  argv 
) [static]

Definition at line 932 of file cont.c.

References Qnil, and rb_ary_new4.

Referenced by fiber_switch(), and rb_cont_call().

NOINLINE ( NORETURN(static void cont_restore_1(rb_context_t *))   ) 

NOINLINE ( static VALUE   cont_capture(volatile int *stat)  ) 

NORETURN ( NOINLINE(static void cont_restore_0(rb_context_t *, VALUE *))   ) 

static VALUE rb_callcc ( VALUE  self  )  [static]

Definition at line 918 of file cont.c.

References cont_capture(), rb_yield(), val, and VALUE.

Referenced by ruby_Init_Continuation_body().

static VALUE rb_cont_call ( int  argc,
VALUE *  argv,
VALUE  contval 
) [static]

Definition at line 1035 of file cont.c.

References rb_context_struct::argc, rb_fiber_struct::cont, cont_restore_0(), rb_context_struct::ensure_array, rb_thread_struct::ensure_list, rb_thread_struct::fiber, GET_THREAD(), GetContPtr, GetFiberPtr, make_passing_arg(), rb_thread_struct::protect_tag, Qnil, rb_eRuntimeError, rb_raise(), rollback_ensure_stack(), rb_context_struct::saved_thread, rb_thread_struct::self, rb_thread_struct::trace_arg, and rb_context_struct::value.

Referenced by ruby_Init_Continuation_body().

VALUE rb_fiber_alive_p ( VALUE  fibval  ) 

Definition at line 1524 of file cont.c.

References GetFiberPtr, Qfalse, Qtrue, rb_fiber_struct::status, and TERMINATED.

Referenced by get_next_values(), and ruby_Init_Fiber_as_Coroutine().

VALUE rb_fiber_current ( void   ) 

Definition at line 1332 of file cont.c.

References rb_fiber_struct::cont, rb_thread_struct::fiber, GET_THREAD(), rb_thread_struct::root_fiber, root_fiber_alloc(), and rb_context_struct::self.

Referenced by fiber_link_join(), fiber_switch(), get_next_values(), next_init(), rb_fiber_s_current(), and return_fiber().

static VALUE rb_fiber_init ( VALUE  fibval  )  [static]

Definition at line 1217 of file cont.c.

References fiber_init(), and rb_block_proc().

Referenced by Init_Cont().

static VALUE rb_fiber_m_resume ( int  argc,
VALUE *  argv,
VALUE  fib 
) [static]

Definition at line 1547 of file cont.c.

References rb_fiber_resume().

Referenced by Init_Cont().

static VALUE rb_fiber_m_transfer ( int  argc,
VALUE *  argv,
VALUE  fibval 
) [static]

Definition at line 1598 of file cont.c.

References GetFiberPtr, rb_fiber_transfer(), and rb_fiber_struct::transfered.

Referenced by ruby_Init_Fiber_as_Coroutine().

VALUE rb_fiber_new ( VALUE(*)(ANYARGS)  func,
VALUE  obj 
)

Definition at line 1223 of file cont.c.

References fiber_alloc(), fiber_init(), rb_cFiber, and rb_proc_new().

Referenced by next_init().

void rb_fiber_reset_root_local_storage ( VALUE  thval  ) 

Definition at line 1502 of file cont.c.

References rb_fiber_struct::cont, rb_thread_struct::fiber, GetFiberPtr, GetThreadPtr, rb_thread_struct::local_storage, rb_thread_struct::root_fiber, and rb_context_struct::saved_thread.

Referenced by ruby_vm_destruct().

VALUE rb_fiber_resume ( VALUE  fibval,
int  argc,
VALUE *  argv 
)

Definition at line 1480 of file cont.c.

References rb_fiber_struct::cont, fiber_switch(), GetFiberPtr, rb_fiber_struct::prev, Qnil, rb_eFiberError, rb_raise(), ROOT_FIBER_CONTEXT, rb_fiber_struct::transfered, and rb_context_struct::type.

Referenced by get_next_values(), and rb_fiber_m_resume().

static VALUE rb_fiber_s_current ( VALUE  klass  )  [static]

Definition at line 1631 of file cont.c.

References rb_fiber_current().

Referenced by ruby_Init_Fiber_as_Coroutine().

static VALUE rb_fiber_s_yield ( int  argc,
VALUE *  argv,
VALUE  klass 
) [static]

Definition at line 1617 of file cont.c.

References rb_fiber_yield().

Referenced by Init_Cont().

void rb_fiber_start ( void   ) 

Definition at line 1270 of file cont.c.

References rb_context_struct::argc, argc, args, argv, rb_proc_t::block, rb_fiber_struct::cont, rb_block_struct::ep, err, rb_thread_struct::errinfo, EXEC_TAG, rb_thread_struct::fiber, rb_thread_struct::first_proc, GET_THREAD(), GetFiberPtr, GetProcPtr, NIL_P, Qnil, RARRAY_CONST_PTR, rb_bug(), rb_fiber_terminate(), rb_threadptr_pending_interrupt_enque(), rb_vm_ep_local_ep(), rb_vm_invoke_proc(), rb_vm_make_jump_tag_but_local_jump(), rb_thread_struct::root_lep, rb_thread_struct::root_svar, RUBY_VM_SET_INTERRUPT, RUNNING, rb_context_struct::saved_thread, rb_fiber_struct::status, TAG_FATAL, TAG_RAISE, TH_POP_TAG, TH_PUSH_TAG, rb_context_struct::value, and VALUE.

static void rb_fiber_terminate ( rb_fiber_t fib  )  [static]

Definition at line 1254 of file cont.c.

References rb_fiber_struct::cont, rb_context_struct::machine, NULL, rb_fiber_transfer(), return_fiber(), rb_context_struct::stack, rb_context_struct::stack_size, rb_fiber_struct::status, TERMINATED, rb_context_struct::value, and VALUE.

Referenced by rb_fiber_start().

VALUE rb_fiber_transfer ( VALUE  fib,
int  argc,
VALUE *  argv 
)

Definition at line 1474 of file cont.c.

References fiber_switch().

Referenced by rb_fiber_m_transfer(), rb_fiber_terminate(), and rb_fiber_yield().

VALUE rb_fiber_yield ( int  argc,
VALUE *  argv 
)

Definition at line 1496 of file cont.c.

References rb_fiber_transfer(), and return_fiber().

Referenced by next_i(), next_ii(), and rb_fiber_s_yield().

VALUE rb_obj_is_fiber ( VALUE  obj  ) 

Definition at line 370 of file cont.c.

References fiber_data_type, Qfalse, Qtrue, and rb_typeddata_is_kind_of().

Referenced by rb_objspace_call_finalizer().

static VALUE return_fiber ( void   )  [static]

Definition at line 1229 of file cont.c.

References GET_THREAD(), GetFiberPtr, NIL_P, rb_fiber_struct::prev, prev, Qnil, rb_eFiberError, rb_fiber_current(), rb_raise(), rb_thread_struct::root_fiber, and VALUE.

Referenced by rb_fiber_terminate(), and rb_fiber_yield().

static void rollback_ensure_stack ( VALUE  self,
rb_ensure_list_t current,
rb_ensure_entry_t target 
) [inline, static]

Definition at line 968 of file cont.c.

References rb_ensure_entry::data2, rb_ensure_entry::e_proc, rb_ensure_list::entry, func, lookup_rollback_func(), rb_ensure_entry::marker, rb_ensure_list::next, Qundef, rb_eRuntimeError, rb_raise(), and VALUE.

Referenced by rb_cont_call().

static rb_fiber_t* root_fiber_alloc ( rb_thread_t th  )  [static]

Definition at line 1314 of file cont.c.

References rb_fiber_struct::cont, fiber_alloc(), fiber_t_alloc(), rb_fiber_struct::next_fiber, rb_fiber_struct::prev_fiber, rb_cFiber, ROOT_FIBER_CONTEXT, RUNNING, rb_fiber_struct::status, and rb_context_struct::type.

Referenced by fiber_store(), and rb_fiber_current().

RUBY_SYMBOL_EXPORT_BEGIN void ruby_Init_Continuation_body ( void   ) 

Definition at line 1678 of file cont.c.

References CLASS_OF, rb_callcc(), rb_cContinuation, rb_cObject, rb_cont_call(), rb_define_class(), rb_define_global_function(), rb_define_method(), rb_undef_alloc_func(), and rb_undef_method().

Referenced by Init_continuation().

void ruby_Init_Fiber_as_Coroutine ( void   ) 

Definition at line 1689 of file cont.c.

References rb_cFiber, rb_define_method(), rb_define_singleton_method(), rb_fiber_alive_p(), rb_fiber_m_transfer(), and rb_fiber_s_current().

Referenced by Init_fiber().

void ruby_register_rollback_func_for_ensure ( VALUE(*)(ANYARGS)  ensure_func,
VALUE(*)(ANYARGS)  rollback_func 
)

Definition at line 947 of file cont.c.

References GET_VM, NULL, st_data_t, st_init_numtable(), st_insert(), and UNLIKELY.

Referenced by Init_Hash().


Variable Documentation

const rb_data_type_t cont_data_type [static]

Initial value:

Definition at line 424 of file cont.c.

const rb_data_type_t cont_data_type [static]

Definition at line 154 of file cont.c.

Referenced by cont_new().

const rb_data_type_t fiber_data_type [static]

Initial value:

Definition at line 1133 of file cont.c.

const rb_data_type_t fiber_data_type [static]

Definition at line 154 of file cont.c.

Referenced by fiber_alloc(), and rb_obj_is_fiber().

VALUE rb_cContinuation [static]

Definition at line 155 of file cont.c.

Referenced by cont_capture(), and ruby_Init_Continuation_body().

VALUE rb_cFiber [static]

Definition at line 156 of file cont.c.

Referenced by Init_Cont(), rb_fiber_new(), root_fiber_alloc(), and ruby_Init_Fiber_as_Coroutine().

VALUE rb_eFiberError [static]

Definition at line 157 of file cont.c.

Referenced by fiber_switch(), Init_Cont(), rb_fiber_resume(), and return_fiber().


Generated on 19 Jul 2016 for Ruby by  doxygen 1.4.7