aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/body_parts/threaded.rb
blob: 34800bf9c7707e26fce6727098e0501780370a4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'action_view/body_parts/future'

module ActionView
  module BodyParts
    class Threaded < Future
      def initialize(concurrent = false, &block)
        super(&block)
        concurrent ? start : work
      end

      protected
        def start
          @worker = Thread.new { work }
        end

        def finish
          @worker.join if @worker && @worker.alive?
        end
    end
  end
end