summaryrefslogtreecommitdiff
path: root/lib/finalize.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/finalize.rb')
-rw-r--r--lib/finalize.rb66
1 files changed, 31 insertions, 35 deletions
diff --git a/lib/finalize.rb b/lib/finalize.rb
index 9b2ffef..a07e67d 100644
--- a/lib/finalize.rb
+++ b/lib/finalize.rb
@@ -1,8 +1,8 @@
#
# finalizer.rb -
-# $Release Version: 0.2$
-# $Revision: 1.3 $
-# $Date: 1998/01/09 08:09:49 $
+# $Release Version: 0.3$
+# $Revision: 1.4 $
+# $Date: 1998/02/27 05:34:33 $
# by Keiju ISHITSUKA
#
# --
@@ -11,44 +11,42 @@
#
# add(obj, dependant, method = :finalize, *opt)
# add_dependency(obj, dependant, method = :finalize, *opt)
-# 依存関係 R_method(obj, dependant) の追加
+# add dependency R_method(obj, dependant)
#
# delete(obj_or_id, dependant, method = :finalize)
# delete_dependency(obj_or_id, dependant, method = :finalize)
-# 依存関係 R_method(obj, dependant) の削除
+# delete dependency R_method(obj, dependant)
# delete_all_dependency(obj_or_id, dependant)
-# 依存関係 R_*(obj, dependant) の削除
+# delete dependency R_*(obj, dependant)
# delete_by_dependant(dependant, method = :finalize)
-# 依存関係 R_method(*, dependant) の削除
+# delete dependency R_method(*, dependant)
# delete_all_by_dependant(dependant)
-# 依存関係 R_*(*, dependant) の削除
+# delete dependency R_*(*, dependant)
# delete_all
-# 全ての依存関係の削除.
+# delete all dependency R_*(*, *)
#
# finalize(obj_or_id, dependant, method = :finalize)
# finalize_dependency(obj_or_id, dependant, method = :finalize)
-# 依存関連 R_method(obj, dependtant) で結ばれるdependantを
-# finalizeする.
+# finalize the dependant connected by dependency R_method(obj, dependtant).
# finalize_all_dependency(obj_or_id, dependant)
-# 依存関連 R_*(obj, dependtant) で結ばれるdependantをfinalizeする.
+# finalize all dependants connected by dependency R_*(obj, dependtant).
# finalize_by_dependant(dependant, method = :finalize)
-# 依存関連 R_method(*, dependtant) で結ばれるdependantをfinalizeする.
+# finalize the dependant connected by dependency R_method(*, dependtant).
# fainalize_all_by_dependant(dependant)
-# 依存関連 R_*(*, dependtant) で結ばれるdependantをfinalizeする.
+# finalize all dependants connected by dependency R_*(*, dependant).
# finalize_all
-# Finalizerに登録される全てのdependantをfinalizeする
+# finalize all dependency registered to the Finalizer.
#
# safe{..}
-# gc時にFinalizerが起動するのを止める.
-#
+# stop invoking Finalizer on GC.
#
module Finalizer
- RCS_ID='-$Header: /home/keiju/var/src/var.lib/ruby/RCS/finalize.rb,v 1.3 1998/01/09 08:09:49 keiju Exp keiju $-'
+ RCS_ID='-$Id: finalize.rb,v 1.4 1998/02/27 05:34:33 keiju Exp keiju $-'
# @dependency: {id => [[dependant, method, *opt], ...], ...}
- # 依存関係 R_method(obj, dependant) の追加
+ # add dependency R_method(obj, dependant)
def add_dependency(obj, dependant, method = :finalize, *opt)
ObjectSpace.call_finalizer(obj)
method = method.intern unless method.kind_of?(Integer)
@@ -61,7 +59,7 @@ module Finalizer
end
alias add add_dependency
- # 依存関係 R_method(obj, dependant) の削除
+ # delete dependency R_method(obj, dependant)
def delete_dependency(id, dependant, method = :finalize)
id = id.id unless id.kind_of?(Integer)
method = method.intern unless method.kind_of?(Integer)
@@ -75,7 +73,7 @@ module Finalizer
end
alias delete delete_dependency
- # 依存関係 R_*(obj, dependant) の削除
+ # delete dependency R_*(obj, dependant)
def delete_all_dependency(id, dependant)
id = id.id unless id.kind_of?(Integer)
method = method.intern unless method.kind_of?(Integer)
@@ -88,30 +86,29 @@ module Finalizer
end
end
- # 依存関係 R_method(*, dependant) の削除
+ # delete dependency R_method(*, dependant)
def delete_by_dependant(dependant, method = :finalize)
method = method.intern unless method.kind_of?(Integer)
- for id in Dependency.keys
+ for id in @dependency.keys
delete(id, dependant, method)
end
end
- # 依存関係 R_*(*, dependant) の削除
+ # delete dependency R_*(*, dependant)
def delete_all_by_dependant(dependant)
for id in @dependency.keys
delete_all_dependency(id, dependant)
end
end
- # 依存関連 R_method(obj, dependtant) で結ばれるdependantをfinalizeす
- # る.
+ # finalize the depandant connected by dependency R_method(obj, dependtant)
def finalize_dependency(id, dependant, method = :finalize)
id = id.id unless id.kind_of?(Integer)
method = method.intern unless method.kind_of?(Integer)
for assocs in @dependency[id]
assocs.delete_if do
|d, m, *o|
- d.send(m, *o) if ret = d == dependant && m == method
+ d.send(m, id, *o) if ret = d == dependant && m == method
ret
end
@dependency.delete(id) if assoc.empty?
@@ -119,20 +116,20 @@ module Finalizer
end
alias finalize finalize_dependency
- # 依存関連 R_*(obj, dependtant) で結ばれるdependantをfinalizeする.
+ # finalize all dependants connected by dependency R_*(obj, dependtant)
def finalize_all_dependency(id, dependant)
id = id.id unless id.kind_of?(Integer)
method = method.intern unless method.kind_of?(Integer)
for assoc in @dependency[id]
assoc.delete_if do
|d, m, *o|
- d.send(m, *o) if ret = d == dependant
+ d.send(m, id, *o) if ret = d == dependant
end
@dependency.delete(id) if assoc.empty?
end
end
- # 依存関連 R_method(*, dependtant) で結ばれるdependantをfinalizeする.
+ # finalize the dependant connected by dependency R_method(*, dependtant)
def finalize_by_dependant(dependant, method = :finalize)
method = method.intern unless method.kind_of?(Integer)
for id in @dependency.keys
@@ -140,14 +137,14 @@ module Finalizer
end
end
- # 依存関連 R_*(*, dependtant) で結ばれるdependantをfinalizeする.
+ # finalize all dependants connected by dependency R_*(*, dependtant)
def fainalize_all_by_dependant(dependant)
for id in @dependency.keys
finalize_all_dependency(id, dependant)
end
end
- # Finalizerに登録されている全てのdependantをfinalizeする
+ # finalize all dependants registered to the Finalizer.
def finalize_all
for id, assocs in @dependency
for dependant, method, *opt in assocs
@@ -157,7 +154,7 @@ module Finalizer
end
end
- # finalize_* を安全に呼び出すためのイテレータ
+ # method to call finalize_* safely.
def safe
old_status = Thread.critical
Thread.critical = TRUE
@@ -167,7 +164,7 @@ module Finalizer
Thread.critical = old_status
end
- # ObjectSpace#add_finalizerへの登録関数
+ # registering function to ObjectSpace#add_finalizer
def final_of(id)
if assocs = @dependency.delete(id)
for dependant, method, *opt in assocs
@@ -202,4 +199,3 @@ module Finalizer
private_class_method :final_of
end
-