Skip to content

Commit

Permalink
Update mux.mt
Browse files Browse the repository at this point in the history
  • Loading branch information
zarutian authored Aug 5, 2016
1 parent dbc5fb2 commit b241e86
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions streams/mux.mt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,27 @@ def makeDemuxingSink (theOnwardSinks :List[Sink]) :Sink {
return 0
}
}
def outSink := object as Sink {}

def outSink := object as Sink {
to run(packet :Bytes) {
# this should now be only getting segments
def chanId := (packet[0] >> 4) & 0x0F
theOnwardSinks[chanId].run(packet.slice(1, packet.size()))
}
to abort(problem) :Vow[Void] {
def vows := [].diverge()
for (i in (0 .. 15)) {
vows.push(theOnwardSinks[i].abort(problem))
}
return whenAllSettled(vows, null)
}
to complete() :Vow[Void] {
def vows := [].diverge()
for (i in (0 .. 15)) {
vows.push(theOnwardSinks[i].complete())
}
return whenAllSettled(vows, null)
}
}
def bufferedSink := makeBufferedSink(b``, completeTo, outSink)
return bufferedSink
}

0 comments on commit b241e86

Please sign in to comment.