ultravisor/lib/ultravisor/child.rb in service_skeleton-2.0.0 vs ultravisor/lib/ultravisor/child.rb in service_skeleton-2.0.1

- old
+ new

@@ -183,17 +183,17 @@ end !!(@restart == :always || (@restart == :on_failure && termination_exception)) end - def unsafe_instance + def unsafe_instance(wait: true) unless @access == :unsafe raise Ultravisor::ThreadSafetyError, "#unsafe_instance called on a child not declared with access: :unsafe" end - current_instance + current_instance(wait: wait) end def cast unless castcall_enabled? raise NoMethodError, @@ -379,10 +379,14 @@ # than the fact that *[] is an empty array, and not a zero-length argument # list, I don't know what it is. Everything else works *so well*, and this... # urgh. if @klass.instance_method(:initialize).arity == 0 @klass.new() + elsif @args.is_a?(Hash) + @klass.new(**@args) + elsif @args.last.is_a?(Hash) + @klass.new(*@args[0...-1], **@args.last) else @klass.new(*@args) end.tap do |i| if castcall_enabled? i.singleton_class.prepend(Ultravisor::Child::ProcessCastCall) @@ -392,12 +396,12 @@ i.instance_variable_set(:@ultravisor_child_castcall_fd, r) end end end - def current_instance + def current_instance(wait: true) @spawn_m.synchronize do - while @instance.nil? + while wait && @instance.nil? @spawn_cv.wait(@spawn_m) end return @instance end