RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.util.Stopwatch Class Reference

Public Member Functions

boolean elapsed (long time)
boolean elapsed (long time, TimeUnit unit)
long elapsedTime ()
long elapsedTime (TimeUnit unit)
boolean finished ()
long getCachedTime ()
Stopwatch reset ()
Stopwatch reset (int delay, TimeUnit unit)
Stopwatch reset (long millis)
void setCachedTime (long cachedTime)
 Stopwatch ()
String toString ()

Static Public Member Functions

static Stopwatch start ()

Private Attributes

long cachedTime

Detailed Description

Definition at line 5 of file Stopwatch.java.

Constructor & Destructor Documentation

◆ Stopwatch()

com.runehive.util.Stopwatch.Stopwatch ( )

Definition at line 9 of file Stopwatch.java.

9 {
10 cachedTime = System.nanoTime();
11 }

References cachedTime.

Referenced by reset(), reset(), reset(), and start().

Here is the caller graph for this function:

Member Function Documentation

◆ elapsed() [1/2]

boolean com.runehive.util.Stopwatch.elapsed ( long time)

Definition at line 53 of file Stopwatch.java.

53 {
54 return elapsed(time, TimeUnit.MILLISECONDS);
55 }

References elapsed().

Here is the call graph for this function:

◆ elapsed() [2/2]

boolean com.runehive.util.Stopwatch.elapsed ( long time,
TimeUnit unit )

◆ elapsedTime() [1/2]

long com.runehive.util.Stopwatch.elapsedTime ( )

Definition at line 45 of file Stopwatch.java.

45 {
46 return elapsedTime(TimeUnit.MILLISECONDS);
47 }

References elapsedTime().

Referenced by elapsed(), elapsedTime(), and toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ elapsedTime() [2/2]

long com.runehive.util.Stopwatch.elapsedTime ( TimeUnit unit)

Definition at line 37 of file Stopwatch.java.

37 {
38 return unit.convert(System.nanoTime() - cachedTime, TimeUnit.NANOSECONDS);
39 }

References cachedTime.

Referenced by com.runehive.content.bloodmoney.BloodChestEvent.execute(), com.runehive.content.skill.impl.magic.spell.impl.Vengeance.execute(), com.runehive.util.Utility.getUptime(), com.runehive.game.engine.GameEngine.runOneIteration(), and com.runehive.game.service.NetworkService.start().

Here is the caller graph for this function:

◆ finished()

boolean com.runehive.util.Stopwatch.finished ( )

Definition at line 41 of file Stopwatch.java.

41 {
42 return cachedTime - System.nanoTime() <= 0;
43 }

References cachedTime.

Referenced by com.runehive.game.world.entity.combat.magic.MagicImpact.freeze(), and com.runehive.game.world.entity.combat.Combat< T extends Mob >.retaliate().

Here is the caller graph for this function:

◆ getCachedTime()

long com.runehive.util.Stopwatch.getCachedTime ( )

Definition at line 57 of file Stopwatch.java.

57 {
58 return cachedTime;
59 }

References cachedTime.

◆ reset() [1/3]

Stopwatch com.runehive.util.Stopwatch.reset ( )

◆ reset() [2/3]

Stopwatch com.runehive.util.Stopwatch.reset ( int delay,
TimeUnit unit )

Definition at line 27 of file Stopwatch.java.

27 {
28 cachedTime = System.nanoTime() + TimeUnit.NANOSECONDS.convert(delay, unit);
29 return this;
30 }

References cachedTime, and Stopwatch().

Here is the call graph for this function:

◆ reset() [3/3]

Stopwatch com.runehive.util.Stopwatch.reset ( long millis)

Definition at line 32 of file Stopwatch.java.

32 {
33 cachedTime = System.nanoTime() + TimeUnit.NANOSECONDS.convert(millis, TimeUnit.MILLISECONDS);
34 return this;
35 }

References cachedTime, and Stopwatch().

Here is the call graph for this function:

◆ setCachedTime()

void com.runehive.util.Stopwatch.setCachedTime ( long cachedTime)

Definition at line 61 of file Stopwatch.java.

61 {
62 this.cachedTime = cachedTime;
63 }

References cachedTime.

◆ start()

Stopwatch com.runehive.util.Stopwatch.start ( )
static

Definition at line 13 of file Stopwatch.java.

13 {
14 return new Stopwatch();
15 }

References Stopwatch().

Referenced by com.runehive.game.engine.GameEngine.runOneIteration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toString()

String com.runehive.util.Stopwatch.toString ( )

Definition at line 18 of file Stopwatch.java.

18 {
19 return String.format("STOPWATCH[elapsed=%d]", elapsedTime());
20 }

References elapsedTime().

Here is the call graph for this function:

Member Data Documentation

◆ cachedTime

long com.runehive.util.Stopwatch.cachedTime
private

The documentation for this class was generated from the following file: