Class PeriodicTimer
java.lang.Object
com.sportradar.livedata.sdk.common.timer.PeriodicTimer
- All Implemented Interfaces:
Timer
A
Timer implementation which raises it's events on a background thread.- Author:
- uros.bregar
-
Constructor Summary
ConstructorsConstructorDescriptionPeriodicTimer(ScheduledExecutorService executorService) Initializes a new instance of thePeriodicTimerclass. -
Method Summary
Modifier and TypeMethodDescriptionvoidschedule(org.joda.time.Duration initialDelay, org.joda.time.Duration period) Schedules a periodic event with specifiedinitialDelayandperiod.voidscheduleOneShot(org.joda.time.Duration delay) Schedules an one-time event to be trigger after time interval specified by passedDuration.voidsetListener(TimerListener listener) Sets theTimerListenerobservation used to observe thisTimerimplementationvoidstop()Un-schedules any events previously registered with calls toTimer.scheduleOneShot(org.joda.time.Duration)orTimer.schedule(org.joda.time.Duration, org.joda.time.Duration).
-
Constructor Details
-
PeriodicTimer
Initializes a new instance of thePeriodicTimerclass.- Parameters:
executorService- TheScheduledExecutorServiceused to schedule the timer's events.- Throws:
IllegalArgumentException- TheexecutorServiceis a null reference orinitialDelayis smaller than zero orperiodis smaller than or equal to zero.
-
-
Method Details
-
setListener
Sets theTimerListenerobservation used to observe thisTimerimplementation- Specified by:
setListenerin interfaceTimer- Parameters:
listener- TheTimerListenerinstance used to observe thisTimeror a null reference.
-
scheduleOneShot
public void scheduleOneShot(org.joda.time.Duration delay) Schedules an one-time event to be trigger after time interval specified by passedDuration. Any events scheduled by previous calls to eitherTimer.scheduleOneShot(org.joda.time.Duration)orTimer.schedule(org.joda.time.Duration, org.joda.time.Duration)are un-scheduled by this call.- Specified by:
scheduleOneShotin interfaceTimer- Parameters:
delay- Specifies the time interval after which the one shot event will be triggered.- Throws:
IllegalArgumentException- Thedelayis a null reference.
-
schedule
public void schedule(org.joda.time.Duration initialDelay, org.joda.time.Duration period) Schedules a periodic event with specifiedinitialDelayandperiod. Any events scheduled by previous calls to eitherTimer.scheduleOneShot(org.joda.time.Duration)orTimer.schedule(org.joda.time.Duration, org.joda.time.Duration)are un-scheduled by this call.- Specified by:
schedulein interfaceTimer- Parameters:
initialDelay- Specifies the time interval after which the one shot event will be triggered.period- Specifies the timer period.- Throws:
IllegalArgumentException- TheinitialDelayis a null reference orperiodis a null reference.
-
stop
public void stop()Un-schedules any events previously registered with calls toTimer.scheduleOneShot(org.joda.time.Duration)orTimer.schedule(org.joda.time.Duration, org.joda.time.Duration). If no events were scheduled it does nothing.
-