added pause option to server threads.

The pause is started by calling intermission(Long.MAX_VALUE)
and can be stopped by calling intermission(0)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2272 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent e1a52bea22
commit 018b3e0832

@ -175,7 +175,10 @@ public abstract class serverAbstractThread extends Thread implements serverThrea
} }
public void intermission(long pause) { public void intermission(long pause) {
this.intermission = System.currentTimeMillis() + pause; if (pause == Long.MAX_VALUE)
this.intermission = Long.MAX_VALUE;
else
this.intermission = System.currentTimeMillis() + pause;
} }
public void terminate(boolean waitFor) { public void terminate(boolean waitFor) {
@ -245,15 +248,25 @@ public abstract class serverAbstractThread extends Thread implements serverThrea
Runtime rt = Runtime.getRuntime(); Runtime rt = Runtime.getRuntime();
while (running) { while (running) {
if ((this.intermissionObedient) && (this.intermission > 0)) { if ((this.intermissionObedient) && (this.intermission > 0) && (this.intermission != Long.MAX_VALUE)) {
long itime = this.intermission - System.currentTimeMillis(); long itime = this.intermission - System.currentTimeMillis();
if (itime > 0) { if (itime > 0) {
logSystem("thread '" + this.getName() + "' breaks for intermission: " + (itime / 1000) + " seconds"); if (itime > this.idlePause) itime = this.idlePause;
ratz(itime); logSystem("thread '" + this.getName()
} + "' breaks for intermission: " + (itime / 1000)
this.intermission = 0; + " seconds");
} ratz(itime);
if (rt.freeMemory() > memprereq) try { }
this.intermission = 0;
}
if (this.intermission == Long.MAX_VALUE) {
// omit Job, paused
logSystem("thread '" + this.getName() + "' paused");
timestamp = System.currentTimeMillis();
ratz(this.idlePause);
idletime += System.currentTimeMillis() - timestamp;
} else if (rt.freeMemory() > memprereq) try {
// do job // do job
timestamp = System.currentTimeMillis(); timestamp = System.currentTimeMillis();
memstamp0 = serverMemory.used(); memstamp0 = serverMemory.used();

Loading…
Cancel
Save