AbstractRuntime.java
1/*******************************************************************************
2 * Copyright (c) 2009, 2010 Mountainminds GmbH & Co. KG and Contributors
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Marc R. Hoffmann - initial API and implementation
10 *
11 * $Id: $
12 *******************************************************************************/
13package org.jacoco.core.runtime;
14
15import org.jacoco.core.data.ExecutionDataStore;
16import org.jacoco.core.data.IExecutionDataVisitor;
17
18/**
19 * Base {@link IRuntime} implementation.
20 *
21 * @author Marc R. Hoffmann
22 * @version $Revision: $
23 */
24public abstract class AbstractRuntime implements IRuntime {
25
26 /** store for execution data */
27 protected final ExecutionDataStore store;
28
29 /** access for this runtime instance */
30 protected final ExecutionDataAccess access;
31
32 /**
33 * Creates a new runtime.
34 */
35 protected AbstractRuntime() {
36 store = new ExecutionDataStore();
37 access = new ExecutionDataAccess(store);
38 }
39
40 public final void collect(final IExecutionDataVisitor visitor,
41 final boolean reset) {
42 synchronized (store) {
43 store.accept(visitor);
44 if (reset) {
45 store.reset();
46 }
47 }
48 }
49
50 public final void reset() {
51 synchronized (store) {
52 store.reset();
53 }
54 }
55
56}