* fn ではなく fn_ を定義しておく
* fn メソッドが呼ばれると fn_ を実行し、{引数=>戻り値} を Hash に記憶する
* 同じ引数で再度 fn メソッドが呼ばれると Hash から戻り値を取り出して返す
* a_to_b ではなく a_to_b_ , b_to_a ではなく b_to_a_ を定義しておく
* a_to_b メソッドが呼ばれると a_to_b_ を実行し、{引数=>戻り値}, {戻り値=>引数}を Hash に記憶する
* 同じ引数で再度 a_to_b メソッドが呼ばれると Hash から戻り値を取り出して返す
* b_to_a メソッドが呼ばれ Hash に戻り値があれば Hash から戻り値を取り出して返す
The eql? method of When::TM::(Temporal)Position is not overridden. It seems that the cost of identification of the argument exceeds the merit of the method cash. I do not recommend applying the methodcash to the method which takes When::TM::(Temporal)Position as an argument.
There is a problem in consistency of hash when this function is used in multi-thread environment.
If the initialize method sets Mutex in instance variable @_m_cash_lock_,
this function gives up use of hash in the critical situation.
class Foo
include MethodCash
def initialize
...
@_m_cash_lock_ = Mutex.new
...
end
end
参考 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/47663
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.