るりまサーチ

最速Rubyリファレンスマニュアル検索!
78件ヒット [1-78件を表示] (0.016秒)
トップページ > クエリ:final[x] > ライブラリ:ビルトイン[x]

別のキーワード

  1. cipher final
  2. openssl final
  3. rm_final
  4. run_final
  5. add_final

クラス

モジュール

キーワード

検索結果

ObjectSpace.#define_finalizer(obj) {|id| ...} -> Array (6102.0)

obj が解放されるときに実行されるファイナライザ proc を 登録します。同じオブジェクトについて複数回呼ばれたときは置き換えで はなく追加登録されます。固定値 0 と proc を配列にして返します。

...ID を引数として実行されます。

=== 使い方の注意

以下は、define_finalizer の使い方の悪い例です。

//emlist[悪い例][ruby]{
class Foo
def initialize
ObjectSpace.define_finalizer(self) {
puts "foo"
}
end
end
Foo.new
GC.start
//}

これは、渡さ...
...ています。

//emlist[例][ruby]{
class Bar
def Bar.callback
proc {
puts "bar"
}
end
def initialize
ObjectSpace.define_finalizer(self, Bar.callback)
end
end
Bar.new
GC.start
//}

proc の呼び出しで発生した大域脱出(exitや例外)は無視されます。
...
...例外の発生の有無を確認しておいた方が良いでしょう。

//emlist[例][ruby]{
class Baz
def initialize
ObjectSpace.define_finalizer self, eval(%q{
proc {
raise "baz" rescue puts $!
raise "baz2"
puts "baz3"
}
}, TOPLEVEL_BINDING)
end...

ObjectSpace.#define_finalizer(obj, proc) -> Array (6102.0)

obj が解放されるときに実行されるファイナライザ proc を 登録します。同じオブジェクトについて複数回呼ばれたときは置き換えで はなく追加登録されます。固定値 0 と proc を配列にして返します。

...ID を引数として実行されます。

=== 使い方の注意

以下は、define_finalizer の使い方の悪い例です。

//emlist[悪い例][ruby]{
class Foo
def initialize
ObjectSpace.define_finalizer(self) {
puts "foo"
}
end
end
Foo.new
GC.start
//}

これは、渡さ...
...ています。

//emlist[例][ruby]{
class Bar
def Bar.callback
proc {
puts "bar"
}
end
def initialize
ObjectSpace.define_finalizer(self, Bar.callback)
end
end
Bar.new
GC.start
//}

proc の呼び出しで発生した大域脱出(exitや例外)は無視されます。
...
...例外の発生の有無を確認しておいた方が良いでしょう。

//emlist[例][ruby]{
class Baz
def initialize
ObjectSpace.define_finalizer self, eval(%q{
proc {
raise "baz" rescue puts $!
raise "baz2"
puts "baz3"
}
}, TOPLEVEL_BINDING)
end...

ObjectSpace.#undefine_finalizer(obj) -> object (6102.0)

obj に対するファイナライザをすべて解除します。 obj を返します。

...finalize"
}
end

def initialize
ObjectSpace.define_finalizer(self, Sample.callback)
end

def undef
ObjectSpace.undefine_finalizer(self)
end
end

Sample.new
GC.start
# => finalize

Sample.new
sample.undef
GC.start
# ※何も出力されない
//}

@see ObjectSpace.#define_final...

Module#ruby2_keywords(method_name, ...) -> nil (50.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...is called
with keyword arguments, the final hash argument is marked with a special
flag such that if it is the final element of a normal argument splat to
another method call, and that method call does not include explicit
keywords or a keyword splat, the final element is interpreted as
keywords. I...

Proc#ruby2_keywords -> proc (50.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

...is called with keyword arguments, the final hash
argument is marked with a special flag such that if it is the final
element of a normal argument splat to another method call, and that
method call does not include explicit keywords or a keyword splat, the
final
element is interpreted as keywords....

絞り込み条件を変える

GC.stat(key) -> Numeric (8.0)

GC 内部の統計情報を Hash で返します。

...{
:count=>2,
:heap_used=>9,
:heap_length=>11,
:heap_increment=>2,
:heap_live_slot=>6836,
:heap_free_slot=>519,
:heap_final_slot=>0,
:heap_swept_slot=>818,
:total_allocated_object=>7674,
:total_freed_object=>838,
:malloc_increase=>181034,
:malloc_lim...
...length=>24,
:heap_allocatable_pages=>0,
:heap_available_slots=>9783,
:heap_live_slots=>7713,
:heap_free_slots=>2070,
:heap_final_slots=>0,
:heap_marked_slots=>0,
:heap_swept_slots=>0,
:heap_eden_pages=>24,
:heap_tomb_pages=>0,
:total_allocated_pages=...

GC.stat(result_hash = {}) -> {Symbol => Integer} (8.0)

GC 内部の統計情報を Hash で返します。

...{
:count=>2,
:heap_used=>9,
:heap_length=>11,
:heap_increment=>2,
:heap_live_slot=>6836,
:heap_free_slot=>519,
:heap_final_slot=>0,
:heap_swept_slot=>818,
:total_allocated_object=>7674,
:total_freed_object=>838,
:malloc_increase=>181034,
:malloc_lim...
...length=>24,
:heap_allocatable_pages=>0,
:heap_available_slots=>9783,
:heap_live_slots=>7713,
:heap_free_slots=>2070,
:heap_final_slots=>0,
:heap_marked_slots=>0,
:heap_swept_slots=>0,
:heap_eden_pages=>24,
:heap_tomb_pages=>0,
:total_allocated_pages=...