Skip to content

Instantly share code, notes, and snippets.

@mboeh
Created March 17, 2012 16:21
Show Gist options
  • Save mboeh/2061679 to your computer and use it in GitHub Desktop.
Save mboeh/2061679 to your computer and use it in GitHub Desktop.
Celluloid thread local issues?
# Just so I'm clear on the issue...
class Donut < ActiveRecord::Base
# ...
end
# This encounters the issue with fiber-local variables...
class Homer
include Celluloid
def initialize; @donuts = []; end
def buy_a_donut(id); @donuts << Donut.find(id); end
def eat_donuts; @donuts.each{|donut| donut.eaten = true; donut.save }; end
end
# But this doesn't?
class Homer
include Celluloid
def buy_and_eat_a_donut(id); Donut.find(id).tap{|donut| donut.eaten = true; donut.save }; end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment