lib/openwfe/utils.rb in openwferu-0.9.11 vs lib/openwfe/utils.rb in openwferu-0.9.12

- old
+ new

@@ -114,10 +114,11 @@ return object if object.kind_of?(Float) return object if object.kind_of?(Fixnum) return object if object.kind_of?(TrueClass) return object if object.kind_of?(FalseClass) + return object if object.kind_of?(Symbol) return object.dup if object.kind_of?(String) #return deep_clone(object) if object.kind_of? REXML::Document @@ -249,10 +250,23 @@ end s end # + # Sets the name of the current thread (the attribute :name if it is + # a ruby thread, the java thread name if we're in JRuby) + # + def set_current_thread_name (name) + if defined?(JRUBY_VERSION) + require 'java' + java.lang.Thread.current_thread.name = "#{name} (Ruby Thread)" + else + Thread.current[:name] = name + end + end + + # # Some code for writing thinks like : # # if async # OpenWFE::call_in_thread "launch()", self do # raw_expression.apply(wi) @@ -266,9 +280,13 @@ def OpenWFE.call_in_thread (caller_name, caller_object=nil, &block) return unless block Thread.new do + + #set_current_thread_name "call_in_thread() for '#{caller_name}'" + set_current_thread_name caller_name + begin #$SAFE = safe_level # # (note) # doesn't work : the block inherits the safety level