Skip to content

Instantly share code, notes, and snippets.

@jeroenr
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeroenr/c926dffc951631465baa to your computer and use it in GitHub Desktop.
Save jeroenr/c926dffc951631465baa to your computer and use it in GitHub Desktop.
def ~>[Out](junction: UniformFanInShape[T, Out])(implicit b: Builder[_]): PortOps[Out, Unit] = {
def bind(n: Int): Unit = {
if (n == junction.inSeq.length)
throw new IllegalArgumentException(s"no more inlets free on $junction")
else if (b.module.upstreams.contains(junction.in(n))) bind(n + 1) // it's already part of the graph
else b.addEdge(importAndGetPort(b), junction.in(n)) // b.add(), add it to the graph
}
bind(0)
junction.out
}
def ~>[Out](junction: UniformFanOutShape[T, Out])(implicit b: Builder[_]): PortOps[Out, Unit] = {
// b.add(), add it to the graph
b.addEdge(importAndGetPort(b), junction.in)
try findOut(b, junction, 0)
catch {
case e: IllegalArgumentException ⇒ new DisabledPortOps(e.getMessage)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment