AbstractRuntime.java
1/*******************************************************************************
2 * Copyright (c) 2009 Mountainminds GmbH & Co. KG and others
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 /**
30 * Creates a new runtime.
31 */
32 protected AbstractRuntime() {
33 store = new ExecutionDataStore();
34 }
35
36 public final void collect(final IExecutionDataVisitor visitor,
37 final boolean reset) {
38 synchronized (store) {
39 store.accept(visitor);
40 if (reset) {
41 store.reset();
42 }
43 }
44 }
45
46 public final void registerClass(final long classid, final String name,
47 final boolean[][] blockdata) {
48 store.put(classid, name, blockdata);
49 }
50
51 public final void reset() {
52 synchronized (store) {
53 store.reset();
54 }
55 }
56
57}