blob: 276138f3ada722466f56cd332845ae71aa057065 [file] [log] [blame]
tom8bf2e6b2014-09-10 20:53:54 -07001package org.onlab.util;
2
3import org.jboss.netty.util.HashedWheelTimer;
4
5/**
6 * Hashed-wheel timer singleton. Care must be taken to shutdown the timer
7 * only when the VM is ready to exit.
8 */
9public final class Timer {
10
11 private static HashedWheelTimer timer;
12
13 // Ban public construction
14 private Timer() {
15 }
16
17 /**
18 * Returns the singleton hashed-wheel timer.
19 *
20 * @return hashed-wheel timer
21 */
22 public static HashedWheelTimer getTimer() {
23 if (Timer.timer == null) {
24 Timer.timer = new HashedWheelTimer();
25 Timer.timer.start();
26 }
27 return Timer.timer;
28 }
29
30}