8000 added Output.unfold · rssh/scala-gopher@cc76722 · GitHub
[go: up one dir, main page]

Skip to content

Commit cc76722

Browse files
committed
added Output.unfold
1 parent fd7ba57 commit cc76722

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/scala/gopher/channels/Output.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ trait Output[A] extends GopherAPIProvider
8282

8383
def writeAll[C <: Iterable[A]](it:C):Unit = macro Output.writeAllImpl[A,C]
8484

85+
def unfold[S](s:S)(f:S=>(S,A)):Unit =
86+
{
87+
var ca=f(s)
88+
val fs = api.select.forever
89+
fs.writingWithFlowTerminationAsync[A](this,ca._2,(ec,ft,a) => Future successful {ca=f(ca._1)} )
90+
fs.go
91+
}
8592

8693
/**
8794
*provide pair from Output and Input `(ready, timeouts)` such that writing to `ready`

0 commit comments

Comments
 (0)
0