Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
e386760c
Commit
e386760c
authored
Nov 04, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Fiber.current
parent
fb831b6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
mrbgems/mruby-fiber/src/fiber.c
mrbgems/mruby-fiber/src/fiber.c
+21
-0
src/gc.c
src/gc.c
+2
-1
No files found.
mrbgems/mruby-fiber/src/fiber.c
View file @
e386760c
...
...
@@ -232,6 +232,26 @@ fiber_yield(mrb_state *mrb, mrb_value self)
return
fiber_result
(
mrb
,
a
,
len
);
}
/*
* call-seq:
* Fiber.current() -> fiber
*
* Returns the current fiber. You need to <code>require 'fiber'</code>
* before using this method. If you are not running in the context of
* a fiber this method will return the root fiber.
*/
static
mrb_value
fiber_current
(
mrb_state
*
mrb
,
mrb_value
self
)
{
if
(
!
mrb
->
c
->
fib
)
{
struct
RFiber
*
f
=
(
struct
RFiber
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_FIBER
,
mrb_class_ptr
(
self
));
f
->
cxt
=
mrb
->
c
;
mrb
->
c
->
fib
=
f
;
}
return
mrb_obj_value
(
mrb
->
c
->
fib
);
}
void
mrb_mruby_fiber_gem_init
(
mrb_state
*
mrb
)
{
...
...
@@ -245,6 +265,7 @@ mrb_mruby_fiber_gem_init(mrb_state* mrb)
mrb_define_method
(
mrb
,
c
,
"alive?"
,
fiber_alive_p
,
MRB_ARGS_NONE
());
mrb_define_class_method
(
mrb
,
c
,
"yield"
,
fiber_yield
,
MRB_ARGS_ANY
());
mrb_define_class_method
(
mrb
,
c
,
"current"
,
fiber_current
,
MRB_ARGS_NONE
());
}
void
...
...
src/gc.c
View file @
e386760c
...
...
@@ -619,7 +619,8 @@ obj_free(mrb_state *mrb, struct RBasic *obj)
{
struct
mrb_context
*
c
=
((
struct
RFiber
*
)
obj
)
->
cxt
;
mrb_free_context
(
mrb
,
c
);
if
(
c
!=
mrb
->
root_c
)
mrb_free_context
(
mrb
,
c
);
}
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment