net.java.dev.moskito.core.timing.timer
Class TimerServiceImpl

java.lang.Object
  extended by net.java.dev.moskito.core.timing.timer.TimerServiceImpl
All Implemented Interfaces:
Runnable, ITimerService

public class TimerServiceImpl
extends Object
implements Runnable, ITimerService

This class implements a basic timer. The timer sleeps unified time, then checks if any consumer want to have a "tick". Each consumer can specify the number of "ticks" in which interval they want to be called.

Author:
Leon Rosenberg

Nested Class Summary
(package private)  class TimerServiceImpl.TimerObject
          The Holder class for the information of upcoming events.
 
Field Summary
private static TimerServiceImpl instance
           
private  List<TimerServiceImpl.TimerObject> objects
           
(package private)  boolean running
           
(package private)  int sleepTime
           
(package private)  Thread thread
          The ticker-thread.
 
Constructor Summary
private TimerServiceImpl()
           
 
Method Summary
 void addConsumer(ITimerConsumer object, int amount)
          Adds a feature to the Consumer attribute of the CIPTimer object
 void deInit()
          Description of the Method
static TimerServiceImpl getInstance()
           
 void init()
          Description of the Method
 void removeConsumer(ITimerConsumer object)
          Description of the Method
 void removeConsumer(ITimerConsumer object, int amount)
          Description of the Method
 void run()
          Main processing method for the CIPTimer object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static TimerServiceImpl instance

sleepTime

int sleepTime

objects

private List<TimerServiceImpl.TimerObject> objects

running

volatile boolean running

thread

Thread thread
The ticker-thread.

Constructor Detail

TimerServiceImpl

private TimerServiceImpl()
Method Detail

getInstance

public static TimerServiceImpl getInstance()

init

public void init()
Description of the Method


deInit

public void deInit()
Description of the Method


addConsumer

public void addConsumer(ITimerConsumer object,
                        int amount)
Adds a feature to the Consumer attribute of the CIPTimer object

Specified by:
addConsumer in interface ITimerService
Parameters:
object - The feature to be added to the Consumer attribute
amount - The feature to be added to the Consumer attribute

removeConsumer

public void removeConsumer(ITimerConsumer object,
                           int amount)
Description of the Method

Specified by:
removeConsumer in interface ITimerService
Parameters:
object - Description of Parameter
amount - Description of Parameter

removeConsumer

public void removeConsumer(ITimerConsumer object)
Description of the Method

Specified by:
removeConsumer in interface ITimerService
Parameters:
object - Description of Parameter

run

public void run()
Main processing method for the CIPTimer object

Specified by:
run in interface Runnable


Copyright © 2006 MoSKito Project Team. All Rights Reserved.
MoSKito, the open source java monitoring framework