Sha256: 021b547150b2d887629e4fea895a8607d3eb33eab18ce143eda0955b31c66745
Contents?: true
Size: 550 Bytes
Versions: 1
Compression:
Stored size: 550 Bytes
Contents
module Elaine class Worker attr_reader :vertices, :active def initialize(graph = []) raise 'empty worker graph' if graph.empty? @vertices = graph @active = graph.size end def superstep Thread.new do @vertices.each do |v| v.messages = PostOffice.instance.read(v.id) v.active! if v.messages.size > 0 end active = @vertices.select {|v| v.active?} active.each {|v| v.step} @active = active.select {|v| v.active?}.size end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
elaine-0.0.3 | lib/elaine/worker.rb |