lib/include/class_knjappserver_threadding.rb in knjappserver-0.0.29 vs lib/include/class_knjappserver_threadding.rb in knjappserver-0.0.30

- old
+ new

@@ -2,15 +2,18 @@ def initialize_threadding @config[:threadding] = {} if !@config.has_key?(:threadding) @config[:threadding][:max_running] = 8 if !@config[:threadding].has_key?(:max_running) @threadpool = Knj::Threadpool.new(:threads => @config[:threadding][:max_running], :sleep => 0.1) - @threadpool.events.connect(:on_error) do |event, error| - self.handle_error(error) - end + @threadpool.events.connect(:on_error, &self.method(:threadpool_on_error)) end + #Callback for when an error occurs in the threadpool. + def threadpool_on_error(event, error) + self.handle_error(error) + end + #Inits the thread so it has access to the appserver and various magic methods can be used. def thread_init(thread = nil) thread = Thread.current if thread == nil thread[:knjappserver] = {} if !thread[:knjappserver] thread[:knjappserver][:kas] = self @@ -69,9 +72,10 @@ end #Spawns a thread to run the given proc and add the output of that block in the correct order to the HTML. def threadded_content(&block) _httpsession.threadded_content(block) + return nil end end class Knjappserver::Thread_instance attr_reader :args \ No newline at end of file