Skip to content

Commit

Permalink
Renamed GC.increase to GC.growth. Improved RDoc for MBARI_API
Browse files Browse the repository at this point in the history
  • Loading branch information
brentr committed Feb 16, 2009
1 parent eda8d43 commit 680a7ad
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
20 changes: 17 additions & 3 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -10113,13 +10113,16 @@ rb_mod_define_method(argc, argv, mod)
}


#if MBARI_API
#ifdef MBARI_API
/*
* call-seq:
* meth.__file__ => String
*
* returns the filename containing this method's definition
*
* raises ArgumentError if method has no associated ruby source code
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/

static VALUE
Expand All @@ -10142,7 +10145,10 @@ method_source_file_name(VALUE method)
* meth.__line__ => Fixnum
*
* returns the starting line number of this method
*
* raises ArgumentError if method has no associated ruby source code
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/

static VALUE
Expand All @@ -10166,7 +10172,10 @@ method_source_line(VALUE method)
* prc.__file__ => String
*
* returns the filename where this proc is defined
*
* raises ArgumentError if proc has no associated ruby source
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/

static VALUE
Expand All @@ -10188,7 +10197,10 @@ proc_source_file_name(VALUE block)
* prc.__line__ => Fixnum
*
* returns the starting line number of this proc
*
* raises ArgumentError if proc has no associated ruby source code
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/

static VALUE
Expand Down Expand Up @@ -10291,7 +10303,7 @@ Init_Proc()
rb_define_method(rb_cUnboundMethod, "bind", umethod_bind, 1);
rb_define_method(rb_cModule, "instance_method", rb_mod_method, 1);

#if MBARI_API
#ifdef MBARI_API
rb_define_method(rb_cUnboundMethod, "__file__", method_source_file_name, 0);
rb_define_method(rb_cUnboundMethod, "__line__", method_source_line, 0);
rb_define_method(rb_cProc, "__file__", proc_source_file_name, 0);
Expand Down Expand Up @@ -13443,13 +13455,15 @@ rb_cont_call(argc, argv, cont)
* cont.thread
*
* Returns the thread on which this continuation can be called
* (or nil if that thread has died)
* or nil if that thread has died
*
* t = Thread.new {callcc{|c| $x=c}; sleep 5}
* sleep 1
* $x.thread #=> t
* sleep 10
* $x.thread #=> nil
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/
static VALUE
rb_cont_thread(cont)
Expand Down
20 changes: 14 additions & 6 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ static VALUE *stack_limit, *gc_stack_limit;
static size_t malloc_increase = 0;
static size_t malloc_limit = GC_MALLOC_LIMIT;

#if MBARI_API
#ifdef MBARI_API
/*
* call-seq:
* GC.limit => increase limit in bytes
*
* Get the # of bytes that may be allocated before triggering
* a mark and sweep by the garbarge collector to reclaim unused storage.
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/
static VALUE gc_getlimit(VALUE mod)
{
Expand All @@ -85,8 +86,9 @@ static VALUE gc_getlimit(VALUE mod)
* GC.limit=5000000 #=> 5000000
* GC.limit #=> 5000000
* GC.limit=-50 #=> 5000000
* GC.limit=0 #=> 0
* GC.limit=0 #=> 0 #functionally equivalent to GC.stress=true
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/
static VALUE gc_setlimit(VALUE mod, VALUE newLimit)
{
Expand All @@ -100,12 +102,13 @@ static VALUE gc_setlimit(VALUE mod, VALUE newLimit)

/*
* call-seq:
* GC.increase
* GC.growth
*
* Get # of bytes that have been allocated since the last mark & sweep
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/
static VALUE gc_increase(VALUE mod)
static VALUE gc_growth(VALUE mod)
{
return ULONG2NUM(malloc_increase);
}
Expand All @@ -117,6 +120,7 @@ static VALUE gc_increase(VALUE mod)
*
* Purge ghost references from recently freed stack space
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/
static VALUE gc_exorcise(VALUE mod)
{
Expand All @@ -133,6 +137,8 @@ static size_t unstressed_malloc_limit = GC_MALLOC_LIMIT;
* GC.stress => true or false
*
* returns current status of GC stress mode.
*
* <i>Only available when MBARI_API extentions are disabled at build time</i>
*/

static VALUE
Expand All @@ -152,6 +158,8 @@ gc_stress_get(self)
* all memory and object allocation.
*
* Since it makes Ruby very slow, it is only for debugging.
*
* <i>Only available when MBARI_API extentions are enabled at build time</i>
*/

static VALUE
Expand Down Expand Up @@ -2170,10 +2178,10 @@ Init_GC()
rb_define_singleton_method(rb_mGC, "start", rb_gc_start, 0);
rb_define_singleton_method(rb_mGC, "enable", rb_gc_enable, 0);
rb_define_singleton_method(rb_mGC, "disable", rb_gc_disable, 0);
#if MBARI_API
#ifdef MBARI_API
rb_define_singleton_method(rb_mGC, "limit", gc_getlimit, 0);
rb_define_singleton_method(rb_mGC, "limit=", gc_setlimit, 1);
rb_define_singleton_method(rb_mGC, "growth", gc_increase, 0);
rb_define_singleton_method(rb_mGC, "growth", gc_growth, 0);
rb_define_singleton_method(rb_mGC, "exorcise", gc_exorcise, 0);
#else
rb_define_singleton_method(rb_mGC, "stress", gc_stress_get, 0);
Expand Down

0 comments on commit 680a7ad

Please sign in to comment.