Methods Summary |
---|
public void | addSuspendDependency(SuspendDependency dep)Adds a dependency that prevents from system suspend.
synchronized (lock) {
if (!dependencies.contains(dep)) {
dependencies.addElement(dep);
}
}
|
public final int | getState()Returns the current state.
return state;
|
public void | registerSubsystem(Subsystem s)Registers a subsystem this one depends on.
synchronized (subsystems) {
if (!subsystems.contains(s)) {
subsystems.addElement(s);
}
}
|
public void | removeSuspendDependency(SuspendDependency dep)Removes dependency that does not prevent from system suspend any more.
Then invokes suspend notification if there are no dependencies left.
synchronized (lock) {
dependencies.removeElement(dep);
updateSuspendStatus();
}
|
public final void | resume()If the current state is SUSPENDED , changes the state to
RESUMING , performs object-specific activation
operations and then changes the state to ACTIVE .
synchronized (lock) {
if (state == SUSPENDED) {
state = RESUMING;
Enumeration subs = subsystems.elements();
while (subs.hasMoreElements()) {
((Subsystem)subs.nextElement()).resume();
}
resumeImpl();
state = ACTIVE;
resumed();
}
}
|
protected void | resumeImpl()Performs object-specific activation operations.
Default implementation makes nothing.
|
void | resumed()Confirms subsystem has been resumed. Listeners/waiters
can be invoked here.
|
public void | suspend()If the current state is ACTIVE , changes the state to
SUSPENDING , and initiates suspend routine. The suspend
routine is pstponed until all suspend dependences are removed.
If there are no dependencies currently, the suspend routine is
invoked immediately.
synchronized (lock) {
if (state == ACTIVE) {
state = SUSPENDING;
updateSuspendStatus();
}
}
|
protected void | suspendImpl()Performs object-specific suspend operations.
Default implementation makes nothing.
|
void | suspended()Confirms subsystem has been suspended. Listeners/waiters
can be invoked here.
|
public void | unregisterSubsystem(Subsystem s)Unregisters a subsystem this one depends on.
synchronized (subsystems) {
subsystems.removeElement(s);
}
|
protected void | updateSuspendStatus()Checks if there are dependencies that prevent from system suspend,
if there are no ones, and the state is SUSPENDING suspend routine.
The suspend routine performs first object-specific ations then
invokes suspend() methods for all registered subsytems.
synchronized (lock) {
if (state == SUSPENDING && 0 == dependencies.size()) {
suspendImpl();
Enumeration subs = subsystems.elements();
while (subs.hasMoreElements()) {
((Subsystem)subs.nextElement()).suspend();
}
state = SUSPENDED;
suspended();
}
}
|