class Bud::LatticePushElement

Attributes

invalidated[RW]
outputs[R]
rescan[RW]
wired_by[R]

Public Class Methods

new(bud_instance) click to toggle source
# File lib/bud/lattice-core.rb, line 119
def initialize(bud_instance)
  @bud_instance = bud_instance
  @wired_by = []
  @outputs = []
  @pendings = []
  @deletes = []
  @invalidated = true
  @rescan = true
end

Public Instance Methods

add_rescan_invalidate(rescan, invalidate) click to toggle source

Rescan and invalidation

# File lib/bud/lattice-core.rb, line 230
def add_rescan_invalidate(rescan, invalidate)
end
check_wiring() click to toggle source
# File lib/bud/lattice-core.rb, line 144
def check_wiring
  if @outputs.empty? and @pendings.empty? and @deletes.empty?
    raise Bud::Error, "no output specified for #{inspect}"
  end
end
flush() click to toggle source
# File lib/bud/lattice-core.rb, line 223
def flush
end
insert(v, source) click to toggle source

Push-based dataflow

# File lib/bud/lattice-core.rb, line 190
def insert(v, source)
  push_out(v)
end
inspect() click to toggle source
# File lib/bud/lattice-core.rb, line 173
def inspect
  "#{self.class}:#{self.object_id.to_s(16)}"
end
invalidate_at_tick(rescan, invalidate) click to toggle source
# File lib/bud/lattice-core.rb, line 233
def invalidate_at_tick(rescan, invalidate)
end
invalidate_cache() click to toggle source
# File lib/bud/lattice-core.rb, line 236
def invalidate_cache
end
method_missing(meth, *args, &blk) click to toggle source
Calls superclass method
# File lib/bud/lattice-core.rb, line 181
def method_missing(meth, *args, &blk)
  if @bud_instance.wiring?
    Bud::PushApplyMethod.new(@bud_instance, self, meth, args, blk)
  else
    super
  end
end
print_wiring(depth=0, accum="") click to toggle source
push_out(v) click to toggle source
# File lib/bud/lattice-core.rb, line 194
def push_out(v)
  @outputs.each do |o|
    # If we're emitting outputs to a traditional Bloom collection, merge
    # operators (e.g., <=, <+) take a collection of tuples, so we need to
    # convert the lattice value into a collection of tuple-like values. For
    # now, we hardcode a single way to do this: we simply assume the value
    # embedded inside the lattice is an Enumerable that contains tuple-like
    # values. We also allow lattice morphisms to just produce Enumerable
    # values directly, so we don't call reveal in that case.
    # XXX: rethink this.
    if o.class <= Bud::BudCollection
      o <= (v.class <= Bud::Lattice ? v.reveal : v)
    else
      o.insert(v, self)
    end
  end
  @pendings.each do |o|
    if o.class <= Bud::BudCollection
      o.pending_merge(v.class <= Bud::Lattice ? v.reveal : v)
    else
      o <+ v
    end
  end
  @deletes.each do |o|
    raise Bud::Error unless o.class <= Bud::BudCollection
    o.pending_delete(v.class <= Bud::Lattice ? v.reveal : v)
  end
end
rescan_at_tick() click to toggle source
# File lib/bud/lattice-core.rb, line 246
def rescan_at_tick
  false
end
stratum_end() click to toggle source
# File lib/bud/lattice-core.rb, line 226
def stratum_end
end
tick() click to toggle source

Tick (delta processing)

# File lib/bud/lattice-core.rb, line 240
def tick
end
tick_deltas() click to toggle source
# File lib/bud/lattice-core.rb, line 243
def tick_deltas
end
wire_to(element, kind=:output) click to toggle source
# File lib/bud/lattice-core.rb, line 129
def wire_to(element, kind=:output)
  case kind
  when :output
    @outputs << element
  when :pending
    @pendings << element
  when :delete
    @deletes << element
  else
    raise Bud::Error, "unrecognized wiring kind: #{kind}"
  end

  element.wired_by << self
end
wirings() click to toggle source
# File lib/bud/lattice-core.rb, line 177
def wirings
  @outputs + @pendings + @deletes
end