Skip to content

Commit

Permalink
Add mrb_fiber_alive_p to C API.
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Mar 2, 2018
1 parent a95b6d3 commit 10f28fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions include/mruby.h
Expand Up @@ -1225,6 +1225,13 @@ MRB_API mrb_value mrb_fiber_resume(mrb_state *mrb, mrb_value fib, mrb_int argc,
*/
MRB_API mrb_value mrb_fiber_yield(mrb_state *mrb, mrb_int argc, const mrb_value *argv);

/*
* Check if a Fiber is alive
*
* @mrbgem mruby-fiber
*/
MRB_API mrb_value mrb_fiber_alive_p(mrb_state *mrb, mrb_value fib);

/*
* FiberError reference
*
Expand Down
5 changes: 3 additions & 2 deletions mrbgems/mruby-fiber/src/fiber.c
Expand Up @@ -274,12 +274,13 @@ mrb_fiber_resume(mrb_state *mrb, mrb_value fib, mrb_int len, const mrb_value *a)
* Returns true if the fiber can still be resumed. After finishing
* execution of the fiber block this method will always return false.
*/
static mrb_value
fiber_alive_p(mrb_state *mrb, mrb_value self)
MRB_API mrb_value
mrb_fiber_alive_p(mrb_state *mrb, mrb_value self)
{
struct mrb_context *c = fiber_check(mrb, self);
return mrb_bool_value(c->status != MRB_FIBER_TERMINATED);
}
#define fiber_alive_p mrb_fiber_alive_p

static mrb_value
fiber_eq(mrb_state *mrb, mrb_value self)
Expand Down

0 comments on commit 10f28fc

Please sign in to comment.