Class PeriodicTimer
- java.lang.Object
-
- com.sportradar.livedata.sdk.common.timer.PeriodicTimer
-
-
Constructor Summary
Constructors Constructor Description PeriodicTimer(ScheduledExecutorService executorService)
Initializes a new instance of thePeriodicTimer
class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
schedule(org.joda.time.Duration initialDelay, org.joda.time.Duration period)
Schedules a periodic event with specifiedinitialDelay
andperiod
.void
scheduleOneShot(org.joda.time.Duration delay)
Schedules an one-time event to be trigger after time interval specified by passedDuration
.void
setListener(TimerListener listener)
Sets theTimerListener
observation used to observe thisTimer
implementationvoid
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)
.
-
-
-
Constructor Detail
-
PeriodicTimer
public PeriodicTimer(ScheduledExecutorService executorService)
Initializes a new instance of thePeriodicTimer
class.- Parameters:
executorService
- TheScheduledExecutorService
used to schedule the timer's events.- Throws:
IllegalArgumentException
- TheexecutorService
is a null reference orinitialDelay
is smaller than zero orperiod
is smaller than or equal to zero.
-
-
Method Detail
-
setListener
public void setListener(TimerListener listener)
Sets theTimerListener
observation used to observe thisTimer
implementation- Specified by:
setListener
in interfaceTimer
- Parameters:
listener
- TheTimerListener
instance used to observe thisTimer
or 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:
scheduleOneShot
in interfaceTimer
- Parameters:
delay
- Specifies the time interval after which the one shot event will be triggered.- Throws:
IllegalArgumentException
- Thedelay
is a null reference.
-
schedule
public void schedule(org.joda.time.Duration initialDelay, org.joda.time.Duration period)
Schedules a periodic event with specifiedinitialDelay
andperiod
. 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:
schedule
in interfaceTimer
- Parameters:
initialDelay
- Specifies the time interval after which the one shot event will be triggered.period
- Specifies the timer period.- Throws:
IllegalArgumentException
- TheinitialDelay
is a null reference orperiod
is 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.
-
-