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 SummaryConstructorsConstructorDescriptionPeriodicTimer(ScheduledExecutorService executorService) Initializes a new instance of thePeriodicTimerclass.
- 
Method SummaryModifier 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- 
PeriodicTimerInitializes a new instance of thePeriodicTimerclass.- Parameters:
- executorService- The- ScheduledExecutorServiceused to schedule the timer's events.
- Throws:
- IllegalArgumentException- The- executorServiceis a null reference or- initialDelayis smaller than zero or- periodis smaller than or equal to zero.
 
 
- 
- 
Method Details- 
setListenerSets theTimerListenerobservation used to observe thisTimerimplementation- Specified by:
- setListenerin interface- Timer
- Parameters:
- listener- The- TimerListenerinstance used to observe this- Timeror a null reference.
 
- 
scheduleOneShotpublic 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 interface- Timer
- Parameters:
- delay- Specifies the time interval after which the one shot event will be triggered.
- Throws:
- IllegalArgumentException- The- delayis a null reference.
 
- 
schedulepublic 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 interface- Timer
- Parameters:
- initialDelay- Specifies the time interval after which the one shot event will be triggered.
- period- Specifies the timer period.
- Throws:
- IllegalArgumentException- The- initialDelayis a null reference or- periodis a null reference.
 
- 
stoppublic 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.
 
-