Top Description Inners Fields Constructors Methods
rx.internal.operators

public final Class OperatorBufferWithTime<T>

extends Object
implements Observable.Operator<List<T>, T>
Class Inheritance
All Implemented Interfaces
rx.Observable.Operator, rx.functions.Func1, rx.functions.Function
Type Parameters
<T>
the buffered value type
Imports
java.util.*, java.util.concurrent.TimeUnit, rx.*, .Observable, .Observable.Operator, .Scheduler.Worker, rx.exceptions.Exceptions, rx.functions.Action0, rx.observers.SerializedSubscriber

This operation takes values from the specified Observable source and stores them in a buffer. Periodically the buffer is emitted and replaced with a new buffer. How often this is done depends on the specified timespan. The creation of chunks is also periodical. How often this is done depends on the specified timeshift. When the source Observable completes or produces an error, the current buffer is emitted, and the event is propagated to all subscribed Subscribers.

Note that this operation can produce non-connected, or overlapping chunks depending on the input parameters.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
OperatorBufferWithTime.ExactSubscriber

Subscriber when exact timed chunking is required.

pack-priv class
OperatorBufferWithTime.InexactSubscriber

Subscriber when the buffer chunking time and length differ.

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final Scheduler
pack-priv final long
pack-priv final long
pack-priv final TimeUnit

Constructor Summary

AccessConstructor and Description
public
OperatorBufferWithTime(long
the amount of time all chunks must be actively collect values before being emitted
timespan
,
long
the amount of time between creating chunks
timeshift
,
TimeUnit
the TimeUnit defining the unit of time for the timespan
unit
,
int
the maximum size of the buffer. Once a buffer reaches this size, it is emitted
count
,
Scheduler
the Scheduler to use for timing chunks
scheduler
)

Method Summary

Modifier and TypeMethod and Description
public Subscriber<? super T>
call(final Subscriber<? super List<T>> child)

Implements rx.functions.Func1.call.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

countback to summary
pack-priv final int count
schedulerback to summary
pack-priv final Scheduler scheduler
timeshiftback to summary
pack-priv final long timeshift
timespanback to summary
pack-priv final long timespan
unitback to summary
pack-priv final TimeUnit unit

Constructor Detail

OperatorBufferWithTimeback to summary
public OperatorBufferWithTime(long timespan, long timeshift, TimeUnit unit, int count, Scheduler scheduler)
Parameters
timespan:long

the amount of time all chunks must be actively collect values before being emitted

timeshift:long

the amount of time between creating chunks

unit:TimeUnit

the TimeUnit defining the unit of time for the timespan

count:int

the maximum size of the buffer. Once a buffer reaches this size, it is emitted

scheduler:Scheduler

the Scheduler to use for timing chunks

Method Detail

callback to summary
public Subscriber<? super T> call(final Subscriber<? super List<T>> child)

Implements rx.functions.Func1.call.

Annotations
@Override
rx.internal.operators back to summary

pack-priv final Class OperatorBufferWithTime.ExactSubscriber

extends Subscriber<T>
Class Inheritance

Subscriber when exact timed chunking is required.

Field Summary

Modifier and TypeField and Description
pack-priv final Subscriber<? super List<T>>
pack-priv List<T>
chunk

Guarded by this.

pack-priv boolean
done

Guarded by this.

pack-priv final Scheduler.Worker

Constructor Summary

AccessConstructor and Description
public
ExactSubscriber(Subscriber<? super List<T>> child, Scheduler.Worker inner)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
emit()

public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(Throwable
the exception encountered by the Observable
e
)

Implements rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public void
onNext(T
the item emitted by the Observable
t
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
pack-priv void
Inherited from rx.Subscriber:
addisUnsubscribedonStartrequestsetProducerunsubscribe

Field Detail

childback to summary
pack-priv final Subscriber<? super List<T>> child
chunkback to summary
pack-priv List<T> chunk

Guarded by this.

doneback to summary
pack-priv boolean done

Guarded by this.

innerback to summary
pack-priv final Scheduler.Worker inner

Constructor Detail

ExactSubscriberback to summary
public ExactSubscriber(Subscriber<? super List<T>> child, Scheduler.Worker inner)

Method Detail

emitback to summary
pack-priv void emit()
onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@Override
onNextback to summary
public void onNext(T t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
scheduleExactback to summary
pack-priv void scheduleExact()
rx.internal.operators back to summary

pack-priv final Class OperatorBufferWithTime.InexactSubscriber

extends Subscriber<T>
Class Inheritance

Subscriber when the buffer chunking time and length differ.

Field Summary

Modifier and TypeField and Description
pack-priv final Subscriber<? super List<T>>
pack-priv final List<List<T>>
chunks

Guarded by this.

pack-priv boolean
done

Guarded by this.

pack-priv final Scheduler.Worker

Constructor Summary

AccessConstructor and Description
public
InexactSubscriber(Subscriber<? super List<T>> child, Scheduler.Worker inner)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
emitChunk(List<T> chunkToEmit)

public void
onCompleted()

Implements rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.
public void
onError(Throwable
the exception encountered by the Observable
e
)

Implements rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.
public void
onNext(T
the item emitted by the Observable
t
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
pack-priv void
pack-priv void
Inherited from rx.Subscriber:
addisUnsubscribedonStartrequestsetProducerunsubscribe

Field Detail

childback to summary
pack-priv final Subscriber<? super List<T>> child
chunksback to summary
pack-priv final List<List<T>> chunks

Guarded by this.

doneback to summary
pack-priv boolean done

Guarded by this.

innerback to summary
pack-priv final Scheduler.Worker inner

Constructor Detail

InexactSubscriberback to summary
public InexactSubscriber(Subscriber<? super List<T>> child, Scheduler.Worker inner)

Method Detail

emitChunkback to summary
pack-priv void emitChunk(List<T> chunkToEmit)
onCompletedback to summary
public void onCompleted()

Implements rx.Observer.onCompleted.

Doc from rx.Observer.onCompleted.

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError.

Annotations
@Override
onErrorback to summary
public void onError(Throwable e)

Implements rx.Observer.onError.

Doc from rx.Observer.onError.

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext or onCompleted.

Parameters
e:Throwable

the exception encountered by the Observable

Annotations
@Override
onNextback to summary
public void onNext(T t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
scheduleChunkback to summary
pack-priv void scheduleChunk()
startNewChunkback to summary
pack-priv void startNewChunk()