Class TimingServiceListener

  • All Implemented Interfaces:
    ServiceListener<java.lang.Object>

    public final class TimingServiceListener
    extends AbstractServiceListener<java.lang.Object>
    implements ServiceListener<java.lang.Object>
    A service listener which times service start. The timing starts from the moment the listener is created and ends when the last service is batched and the services are all started.
    • Field Detail

      • finished

        private volatile int finished
      • count

        private volatile int count
      • totalServices

        private volatile int totalServices
      • start

        private final long start
      • end

        private volatile long end
      • finishedTask

        private final java.lang.Runnable finishedTask
      • finishedUpdater

        private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener> finishedUpdater
      • countUpdater

        private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener> countUpdater
      • totalServicesUpdater

        private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener> totalServicesUpdater
    • Constructor Detail

      • TimingServiceListener

        public TimingServiceListener()
        Construct a new instance.
      • TimingServiceListener

        public TimingServiceListener​(java.lang.Runnable finishedTask)
        Construct a new instance which calls the given task when the timing is done.
        Parameters:
        finishedTask - the finish task
    • Method Detail

      • done

        private void done()
      • finishBatch

        public void finishBatch()
        Call when all services in this timing group have been added.
      • finished

        public boolean finished()
        Determine whether all services have finished.
        Returns:
        true if all services have finished
      • getRemainingCount

        public int getRemainingCount()
        Get the number of remaining services to start.
        Returns:
        the remaining count
      • getTotalCount

        public int getTotalCount()
        Get the total number of services being tracked.
        Returns:
        the total count
      • getElapsedTime

        public long getElapsedTime()
        Get the elapsed time in milliseconds.
        Returns:
        the elapsed time, or -1 if not finished yet