Class: Dataflow::FutureQueue

Inherits:
Object
  • Object
show all
Includes:
Dataflow
Defined in:
lib/vendor/dataflow/dataflow/future_queue.rb

Constant Summary

Constants included from Dataflow

UnificationError, VERSION

Instance Method Summary collapse

Methods included from Dataflow

#barrier, #by_need, #flow, included, #local, #need_later, #unify

Constructor Details

#initializeFutureQueue

Returns a new instance of FutureQueue.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/vendor/dataflow/dataflow/future_queue.rb', line 6

def initialize
  local do |pushed, popped|
    unify push_port, Dataflow::Port.new(pushed)
    unify pop_port, Dataflow::Port.new(popped)
    
    Thread.new {
      loop do
        barrier pushed.head, popped.head
        unify popped.head, pushed.head
        pushed, popped = pushed.tail, popped.tail
      end
    }
  end
end

Instance Method Details

#pop(x) ⇒ Object



22
# File 'lib/vendor/dataflow/dataflow/future_queue.rb', line 22

def pop(x) pop_port.send x end

#push(x) ⇒ Object



21
# File 'lib/vendor/dataflow/dataflow/future_queue.rb', line 21

def push(x) push_port.send x end