1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* server/src/com/vettalabs/petaverse/plugins/TickTimerTask.java
*
* Copyright (C) 2002-2009 Novamente LLC
* All Rights Reserved
* Author(s): Carlos Lopes
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License v3 as
* published by the Free Software Foundation and including the exceptions
* at http://opencog.org/wiki/Licenses
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program; if not, write to:
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.vettalabs.petaverse.plugins;
import java.util.TimerTask;
import multiverse.server.util.Log;
/**
* @author Carlos Lopes
*
*/
public class TickTimerTask extends TimerTask {
/**
* The PetaverseProxy object used to send messages.
*/
private PetaverseProxy proxy;
private long lastTime, interval;
/**
*
* @param proxy
*/
public TickTimerTask(PetaverseProxy proxy, long interval) {
super();
this.proxy = proxy;
this.lastTime = System.currentTimeMillis();
this.interval = interval;
}
/**
*
*/
public void run() {
long curTime = System.currentTimeMillis();
long elapsedTime = curTime - lastTime;
if (elapsedTime > (interval + 10)) {
if (Log.loggingDebug) Log.debug("TickTimerTask: delayed => " + elapsedTime);
}
lastTime = curTime;
proxy.timeTick();
}
}
|