class Rbgo::Once
Attributes
called_flag[RW]
mutex[RW]
Public Class Methods
new()
click to toggle source
# File lib/rbgo/once.rb, line 6 def initialize self.mutex = Mutex.new self.called_flag = false end
Public Instance Methods
do(&f)
click to toggle source
# File lib/rbgo/once.rb, line 11 def do(&f) return nil if called_flag mutex.synchronize do unless called_flag begin f.call ensure self.called_flag = true end end end end