Skip to content

Instantly share code, notes, and snippets.

@DanielVartanov
Created November 10, 2014 16:13
Show Gist options
  • Save DanielVartanov/f1f3b6b5072f0b65c2c9 to your computer and use it in GitHub Desktop.
Save DanielVartanov/f1f3b6b5072f0b65c2c9 to your computer and use it in GitHub Desktop.
require 'celluloid'
class Cell
include Celluloid
def expensive
puts "[Started]"
puts thread_count
10000000.times { 1 + 1 }
puts thread_count
puts "[Finished]"
end
def thread_count
Thread.list.select {|thread| thread.status == "run"}.count
end
end
cell = Cell.new
3.times.map do
cell.async.expensive
end
sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment