!str #16492 Remove closure in TickSource to make it shareable

This commit is contained in:
Patrik Nordwall 2015-01-26 14:16:57 +01:00
parent af4555ce1f
commit 631b4ca5ac
8 changed files with 37 additions and 60 deletions

View file

@ -95,14 +95,14 @@ object Source {
new Source(scaladsl.Source(future))
/**
* Elements are produced from the tick closure periodically with the specified interval.
* Elements are emitted periodically with the specified interval.
* The tick element will be delivered to downstream consumers that has requested any elements.
* If a consumer has not requested any elements at the point in time when the tick
* element is produced it will not receive that tick element later. It will
* receive new tick elements as soon as it has requested more elements.
*/
def from[O](initialDelay: FiniteDuration, interval: FiniteDuration, tick: Callable[O]): javadsl.KeyedSource[O, Cancellable] =
new KeyedSource(scaladsl.Source(initialDelay, interval, () tick.call()))
def from[O](initialDelay: FiniteDuration, interval: FiniteDuration, tick: O): javadsl.KeyedSource[O, Cancellable] =
new KeyedSource(scaladsl.Source(initialDelay, interval, tick))
/**
* Creates a `Source` by using a [[FlowGraphBuilder]] from this [[PartialFlowGraph]] on a block that expects