--- /dev/null
+/*\r
+ * \r
+ * Copyright 2001-2004 The Ant-Contrib project\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package net.sf.antcontrib.cpptasks;\r
+import java.io.IOException;\r
+\r
+import net.sf.antcontrib.cpptasks.compiler.ProcessorConfiguration;\r
+import net.sf.antcontrib.cpptasks.compiler.ProgressMonitor;\r
+public class CCTaskProgressMonitor implements ProgressMonitor {\r
+ private ProcessorConfiguration config;\r
+ private TargetHistoryTable history;\r
+ private long lastCommit = -1;\r
+ public CCTaskProgressMonitor(TargetHistoryTable history) {\r
+ this.history = history;\r
+ }\r
+ public void finish(ProcessorConfiguration config, boolean normal) {\r
+ long current = System.currentTimeMillis();\r
+ if ((current - lastCommit) > 120000) {\r
+ try {\r
+ history.commit();\r
+ lastCommit = System.currentTimeMillis();\r
+ } catch (IOException ex) {\r
+ }\r
+ }\r
+ }\r
+ public void progress(String[] sources) {\r
+ history.update(config, sources);\r
+ long current = System.currentTimeMillis();\r
+ if ((current - lastCommit) > 120000) {\r
+ try {\r
+ history.commit();\r
+ lastCommit = current;\r
+ } catch (IOException ex) {\r
+ }\r
+ }\r
+ }\r
+ public void start(ProcessorConfiguration config) {\r
+ if (lastCommit < 0) {\r
+ lastCommit = System.currentTimeMillis();\r
+ }\r
+ this.config = config;\r
+ }\r
+}\r