You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ni...@apache.org on 2008/03/03 08:42:36 UTC

svn commit: r632969 - /commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/StopWatch.java

Author: nicolas
Date: Sun Mar  2 23:42:35 2008
New Revision: 632969

URL: http://svn.apache.org/viewvc?rev=632969&view=rev
Log:
missing StopWatch interface

Added:
    commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/StopWatch.java   (with props)

Added: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/StopWatch.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/StopWatch.java?rev=632969&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/StopWatch.java (added)
+++ commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/StopWatch.java Sun Mar  2 23:42:35 2008
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.monitoring;
+
+/**
+ *
+ * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
+ */
+public interface StopWatch
+{
+    /**
+     * @return Elapsed time (in nanoseconds) for the monitored process, not
+     * including paused time
+     */
+    public abstract long getElapsedTime();
+
+    /**
+     * Temporary stop the StopWatch. Elapsed time calculation will not include
+     * time spent in paused mode.
+     */
+    public abstract void pause();
+
+    /**
+     * Resume the StopWatch after a pause.
+     */
+    public abstract void resume();
+
+    /**
+     * Stop monitoring the process. A StopWatch created with
+     * {@link #start(Monitor)} cannot be re-used after stopped has been called.
+     */
+    public abstract void stop();
+
+    /**
+     * Convenience method to stop or cancel a Stopwatch depending on success of
+     * monitored operation
+     *
+     * @param canceled
+     * @return time elapsed since the probe has been started
+     */
+    public abstract void stop( boolean canceled );
+
+    /**
+     * Cancel monitoring. Elapsed time will not be computed and will not be
+     * published to the monitor.
+     * <p>
+     * In some circumstances you want to monitor time elapsed from early stage
+     * of computation, and discover latter if the computed data is relevant. For
+     * example, monitoring a messaging system, but beeing interested only by
+     * some types of messages. In such case, a StopWatch can be started early
+     * and canceled when the application is able to determine it's relevancy.
+     * <p>
+     * In any way, the probe will still report thread concurrency even if
+     * canceled.
+     */
+    public abstract void cancel();
+
+    /**
+     * @return <code>true</code> if the StopWatch has been stopped
+     */
+    public abstract boolean isStoped();
+
+    /**
+     * @return <code>true</code> if the StopWatch has been paused
+     */
+    public abstract boolean isPaused();
+
+    public abstract Monitor getMonitor();
+
+}
\ No newline at end of file

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/StopWatch.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/StopWatch.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/StopWatch.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain