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
8d017ebd
Commit
8d017ebd
authored
Aug 09, 2012
by
Yukihiro Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add GC.disable and GC.enable
parent
6b2e0b21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
include/mruby.h
include/mruby.h
+3
-2
src/gc.c
src/gc.c
+49
-0
No files found.
include/mruby.h
View file @
8d017ebd
...
@@ -268,8 +268,9 @@ typedef struct mrb_state {
...
@@ -268,8 +268,9 @@ typedef struct mrb_state {
struct
RBasic
*
variable_gray_list
;
/* list of objects to be traversed atomically */
struct
RBasic
*
variable_gray_list
;
/* list of objects to be traversed atomically */
size_t
gc_live_after_mark
;
size_t
gc_live_after_mark
;
size_t
gc_threshold
;
size_t
gc_threshold
;
mrb_int
gc_interval_ratio
;
int
gc_interval_ratio
;
mrb_int
gc_step_ratio
;
int
gc_step_ratio
;
int
gc_disabled
;
mrb_sym
symidx
;
mrb_sym
symidx
;
struct
kh_n2s
*
name2sym
;
/* symbol table */
struct
kh_n2s
*
name2sym
;
/* symbol table */
...
...
src/gc.c
View file @
8d017ebd
...
@@ -796,6 +796,7 @@ mrb_incremental_gc(mrb_state *mrb)
...
@@ -796,6 +796,7 @@ mrb_incremental_gc(mrb_state *mrb)
{
{
size_t
limit
=
0
,
result
=
0
;
size_t
limit
=
0
,
result
=
0
;
if
(
mrb
->
gc_disabled
)
return
;
GC_INVOKE_TIME_REPORT
;
GC_INVOKE_TIME_REPORT
;
GC_TIME_START
;
GC_TIME_START
;
...
@@ -826,6 +827,7 @@ mrb_garbage_collect(mrb_state *mrb)
...
@@ -826,6 +827,7 @@ mrb_garbage_collect(mrb_state *mrb)
{
{
size_t
max_limit
=
~
0
;
size_t
max_limit
=
~
0
;
if
(
mrb
->
gc_disabled
)
return
;
GC_INVOKE_TIME_REPORT
;
GC_INVOKE_TIME_REPORT
;
GC_TIME_START
;
GC_TIME_START
;
...
@@ -916,6 +918,51 @@ gc_start(mrb_state *mrb, mrb_value obj)
...
@@ -916,6 +918,51 @@ gc_start(mrb_state *mrb, mrb_value obj)
return
mrb_nil_value
();
return
mrb_nil_value
();
}
}
/*
* call-seq:
* GC.enable -> true or false
*
* Enables garbage collection, returning <code>true</code> if garbage
* collection was previously disabled.
*
* GC.disable #=> false
* GC.enable #=> true
* GC.enable #=> false
*
*/
static
mrb_value
gc_enable
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
int
old
=
mrb
->
gc_disabled
;
mrb
->
gc_disabled
=
FALSE
;
if
(
old
)
return
mrb_true_value
();
return
mrb_false_value
();
}
/*
* call-seq:
* GC.disable -> true or false
*
* Disables garbage collection, returning <code>true</code> if garbage
* collection was already disabled.
*
* GC.disable #=> false
* GC.disable #=> true
*
*/
static
mrb_value
gc_disable
(
mrb_state
*
mrb
,
mrb_value
obj
)
{
int
old
=
mrb
->
gc_disabled
;
mrb
->
gc_disabled
=
TRUE
;
if
(
old
)
return
mrb_true_value
();
return
mrb_false_value
();
}
/*
/*
* call-seq:
* call-seq:
* GC.interval_ratio -> fixnum
* GC.interval_ratio -> fixnum
...
@@ -989,6 +1036,8 @@ mrb_init_gc(mrb_state *mrb)
...
@@ -989,6 +1036,8 @@ mrb_init_gc(mrb_state *mrb)
gc
=
mrb_define_module
(
mrb
,
"GC"
);
gc
=
mrb_define_module
(
mrb
,
"GC"
);
mrb_define_class_method
(
mrb
,
gc
,
"start"
,
gc_start
,
ARGS_NONE
());
mrb_define_class_method
(
mrb
,
gc
,
"start"
,
gc_start
,
ARGS_NONE
());
mrb_define_class_method
(
mrb
,
gc
,
"enable"
,
gc_enable
,
ARGS_NONE
());
mrb_define_class_method
(
mrb
,
gc
,
"disable"
,
gc_disable
,
ARGS_NONE
());
mrb_define_class_method
(
mrb
,
gc
,
"interval_ratio"
,
gc_interval_ratio_get
,
ARGS_NONE
());
mrb_define_class_method
(
mrb
,
gc
,
"interval_ratio"
,
gc_interval_ratio_get
,
ARGS_NONE
());
mrb_define_class_method
(
mrb
,
gc
,
"interval_ratio="
,
gc_interval_ratio_set
,
ARGS_REQ
(
1
));
mrb_define_class_method
(
mrb
,
gc
,
"interval_ratio="
,
gc_interval_ratio_set
,
ARGS_REQ
(
1
));
mrb_define_class_method
(
mrb
,
gc
,
"step_ratio"
,
gc_step_ratio_get
,
ARGS_NONE
());
mrb_define_class_method
(
mrb
,
gc
,
"step_ratio"
,
gc_step_ratio_get
,
ARGS_NONE
());
...
...
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