|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A DaemonService provides a background service which is suitable for asynchronous I/O and general clean up. It should not be used as a general worker thread for parallel execution. A DaemonService can be subscribe to by many Serviceable objects and a DaemonService will call that object's performWork from time to time. These performWork method is defined by the client object and should be well behaved - in other words, it should not take too long or hog too many resources or deadlock with anyone else. And it cannot (should not) error out.
MT - all routines on the interface must be MT-safe.
Serviceable
Field Summary | |
static java.lang.String |
DaemonOff
Trace flag that can be used to turn off background daemons If DaemonOff is set, background Daemon will not attempt to do anything. |
static java.lang.String |
DaemonTrace
Trace flag that can be used by Daemons to print stuff out |
static int |
TIMER_DELAY
|
Method Summary | |
void |
clear()
Clear all the queued up work from this daemon. |
boolean |
enqueue(Serviceable newClient,
boolean serviceNow)
Request a one time service from the Daemon. |
void |
pause()
Pause. |
void |
resume()
Resume service after a pause |
void |
serviceNow(int clientNumber)
Service this subscription ASAP. |
void |
stop()
End this daemon service |
int |
subscribe(Serviceable newClient,
boolean onDemandOnly)
Add a new client that this daemon needs to service |
void |
unsubscribe(int clientNumber)
Get rid of a client from the daemon. |
void |
waitUntilQueueIsEmpty()
|
Field Detail |
public static final int TIMER_DELAY
public static final java.lang.String DaemonTrace
public static final java.lang.String DaemonOff
Method Detail |
public int subscribe(Serviceable newClient, boolean onDemandOnly)
newClient
- a Serviceable object this daemon will service from time to timeonDemandOnly
- only service this client when it ask for service with a serviceNow request
public void unsubscribe(int clientNumber)
clientNumber
- the number that uniquely identify the clientpublic void serviceNow(int clientNumber)
clientNumber
- the number that uniquely identify the clientpublic boolean enqueue(Serviceable newClient, boolean serviceNow)
newClient
- the object that needs a one time serviceserviceNow
- if true, this client should be serviced ASAP, as if a
serviceNow has been issued. If false, then this client will be
serviced with the normal scheduled.
public void pause()
public void resume()
public void stop()
public void clear()
public void waitUntilQueueIsEmpty()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |