Module: ThreadImmutable

Defined Under Namespace

Modules: ClassMethods Classes: IllegalCrossThreadMethodCall

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



147
148
149
# File 'lib/wakame/util.rb', line 147

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#bind_thread(thread = Thread.current) ⇒ Object



175
176
177
178
# File 'lib/wakame/util.rb', line 175

def bind_thread(thread=Thread.current)
  @target_thread = thread
  #puts "bound thread: #{@target_thread.inspect} to #{self.class} object"
end

#target_threadObject



191
192
193
# File 'lib/wakame/util.rb', line 191

def target_thread
  @target_thread
end

#target_thread?(t = Thread.current) ⇒ Boolean

Returns:

  • (Boolean)


186
187
188
# File 'lib/wakame/util.rb', line 186

def target_thread?(t=Thread.current)
  @target_thread == t
end

#thread_checkObject



180
181
182
183
184
# File 'lib/wakame/util.rb', line 180

def thread_check
  #puts "@target_thread == Thread.main : #{@target_thread == Thread.main}"
  raise "Thread is not bound." if @target_thread.nil?
  raise IllegalCrossThreadMethodCall unless target_thread?
end