| org.apache.derby.iapi.services.daemon.DaemonService
All known Subclasses: org.apache.derby.impl.services.daemon.BasicDaemon,
DaemonService | public interface DaemonService (Code) | | 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. The 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.
It is up to each DaemonService implementation to define its
level of service, including
- how quickly and how often the clients should expect to be be serviced
- how the clients are prioritized
- whether the clients need to tolerate spurious services
MT - all routines on the interface must be MT-safe.
See Also: Serviceable |
Field Summary | |
final public static 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. | final public static String | DaemonTrace | public static int | TIMER_DELAY |
DaemonOff | final public static String DaemonOff(Code) | | Trace flag that can be used to turn off background daemons
If DaemonOff is set, background Daemon will not attempt to do anything.
|
DaemonTrace | final public static String DaemonTrace(Code) | | Trace flag that can be used by Daemons to print stuff out
|
TIMER_DELAY | public static int TIMER_DELAY(Code) | | |
clear | public void clear()(Code) | | Clear all the queued up work from this daemon. Subscriptions are not
affected.
|
enqueue | public boolean enqueue(Serviceable newClient, boolean serviceNow)(Code) | | Request a one time service from the Daemon. Unless performWork returns
REQUEUE (see Serviceable), the daemon will service this client once
and then it will get rid of this client. Since no client number is
associated with this client, it cannot request to be serviced or be
unsubscribed.
The work is always added to the deamon, regardless of the
state it returns.
Parameters: newClient - the object that needs a one time service Parameters: serviceNow - if true, this client should be serviced ASAP, as if aserviceNow has been issued. If false, then this client will beserviced with the normal scheduled. true if the daemon indicates it is being overloaded,false it's happy. |
pause | public void pause()(Code) | | Pause. No new service is performed until a resume is issued.
|
resume | public void resume()(Code) | | Resume service after a pause
|
serviceNow | public void serviceNow(int clientNumber)(Code) | | Service this subscription ASAP. Does not guarantee that the daemon
will actually do anything about it.
Parameters: clientNumber - the number that uniquely identify the client |
stop | public void stop()(Code) | | End this daemon service
|
subscribe | public int subscribe(Serviceable newClient, boolean onDemandOnly)(Code) | | Add a new client that this daemon needs to service
Parameters: newClient - a Serviceable object this daemon will service from time to time Parameters: onDemandOnly - only service this client when it ask for service with a serviceNow request a client number that uniquely identifies this client (this subscription) |
unsubscribe | public void unsubscribe(int clientNumber)(Code) | | Get rid of a client from the daemon. If a client is being serviced when
the call is made, the implementation may choose whether or not the call
should block until the client has completed its work. If the call does
not block, the client must be prepared to handle calls to its
performWork() method even after unsubscribe()
has returned.
Parameters: clientNumber - the number that uniquely identify the client |
waitUntilQueueIsEmpty | public void waitUntilQueueIsEmpty()(Code) | | |
|
|