diff options
Diffstat (limited to 'actionpack/lib/action_view/body_parts/threaded.rb')
-rw-r--r-- | actionpack/lib/action_view/body_parts/threaded.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/body_parts/threaded.rb b/actionpack/lib/action_view/body_parts/threaded.rb new file mode 100644 index 0000000000..34800bf9c7 --- /dev/null +++ b/actionpack/lib/action_view/body_parts/threaded.rb @@ -0,0 +1,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 |