Interface SchedulingService
- All Superinterfaces:
TimeProvider
Interface for a service that allows to add and remove handles (typically storing callbacks)
for a certain time which are returned when
the evaluate method is invoked and the current time is on or after the handle's registered time.
It is the expectation that the setTime method is called
with same or ascending values for each subsequent call. Handles with are triggered are automatically removed
by implementations.
-
Field Summary
Fields inherited from interface com.espertech.esper.common.internal.schedule.TimeProvider
EPTYPE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long afterMSec, ScheduleHandle handle, long scheduleSlot) Add a callback for after the given milliseconds from the current time.void
destroy()
Destroy the service.void
evaluate
(Collection<ScheduleHandle> handles) Evaluate the current time and add to the collection any handles scheduled for execution.Returns furthest in the future handle.int
Returns count of handles.int
Returns time handle count.boolean
isScheduled
(ScheduleHandle handle) Returns true if the handle has been scheduled already.void
remove
(ScheduleHandle handle, long scheduleSlot) Remove a handle.void
setTime
(long timestamp) Set the time based upon which the evaluation of events invokes callbacks.Methods inherited from interface com.espertech.esper.common.internal.schedule.TimeProvider
getDefaultFormatter, getTime
-
Method Details
-
add
Add a callback for after the given milliseconds from the current time. If the same callback (equals) was already added before, the method will not add a new callback or change the existing callback to a new time, but throw an exception.- Parameters:
afterMSec
- number of millisec to get a callbackhandle
- to addscheduleSlot
- allows ordering of concurrent callbacks- Throws:
ScheduleServiceException
- thrown if the add operation did not complete
-
remove
Remove a handle. If the handle to be removed was not found an exception is thrown.- Parameters:
handle
- to removescheduleSlot
- for which the callback was added- Throws:
ScheduleServiceException
- thrown if the callback was not located
-
setTime
void setTime(long timestamp) Set the time based upon which the evaluation of events invokes callbacks.- Parameters:
timestamp
- to set
-
evaluate
Evaluate the current time and add to the collection any handles scheduled for execution.- Parameters:
handles
- is a collection of handles populated by the service with any callbacks due for the current time
-
destroy
void destroy()Destroy the service. -
getTimeHandleCount
int getTimeHandleCount()Returns time handle count.- Returns:
- count
-
getFurthestTimeHandle
Long getFurthestTimeHandle()Returns furthest in the future handle.- Returns:
- future handle
-
getScheduleHandleCount
int getScheduleHandleCount()Returns count of handles.- Returns:
- count
-
isScheduled
Returns true if the handle has been scheduled already.- Parameters:
handle
- to check- Returns:
- indicator whether the handle is in use
-