From d3cc7a06d4f9b6a500a5da6bf844cc8406efe1ea Mon Sep 17 00:00:00 2001
From: brinn <brinn>
Date: Tue, 2 Oct 2007 21:00:48 +0000
Subject: [PATCH] add: TimerHelper providing a method asTerminable() for Timers

SVN: 1900
---
 .../cisd/common/utilities/TimerHelper.java    | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 common/source/java/ch/systemsx/cisd/common/utilities/TimerHelper.java

diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/TimerHelper.java b/common/source/java/ch/systemsx/cisd/common/utilities/TimerHelper.java
new file mode 100644
index 00000000000..e671cd4f0d6
--- /dev/null
+++ b/common/source/java/ch/systemsx/cisd/common/utilities/TimerHelper.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2007 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.common.utilities;
+
+import java.util.Timer;
+
+/**
+ * Helper methods for timer operations.
+ *
+ * @author Bernd Rinn
+ */
+public class TimerHelper
+{
+
+    /**
+     * Returns an {@link ITerminable} for the <var>timer</var>. 
+     */
+    public static ITerminable asTerminable(final Timer timer)
+    {
+        return new ITerminable()
+            {
+                public boolean terminate()
+                {
+                    timer.cancel();
+                    return true;
+                }
+            };
+    }
+
+}
-- 
GitLab