EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.simucomframework.fork]

COVERAGE SUMMARY FOR SOURCE FILE [ForkedBehaviourProcess.java]

nameclass, %method, %block, %line, %
ForkedBehaviourProcess.java0%   (0/1)0%   (0/6)0%   (0/102)0%   (0/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ForkedBehaviourProcess0%   (0/1)0%   (0/6)0%   (0/102)0%   (0/22)
<static initializer> 0%   (0/1)0%   (0/5)0%   (0/2)
ForkedBehaviourProcess (Context, String, boolean): void 0%   (0/1)0%   (0/40)0%   (0/9)
internalLifeCycle (): void 0%   (0/1)0%   (0/45)0%   (0/8)
isAsync (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
isTerminated (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
simulationIsRunning (): boolean 0%   (0/1)0%   (0/6)0%   (0/1)

1package de.uka.ipd.sdq.simucomframework.fork;
2 
3import org.apache.log4j.Logger;
4 
5import de.uka.ipd.sdq.probespec.framework.RequestContext;
6import de.uka.ipd.sdq.probespec.framework.garbagecollection.IRegionBasedGarbageCollector;
7import de.uka.ipd.sdq.simucomframework.Context;
8import de.uka.ipd.sdq.simucomframework.SimuComSimProcess;
9import de.uka.ipd.sdq.simulation.abstractsimengine.ISimProcess;
10 
11/**
12 * Base class for ForkBehaviours. Generator creates a specialisation of this and
13 * uses it to execute actions in parallel
14 * 
15 * @author Steffen Becker
16 * 
17 */
18public abstract class ForkedBehaviourProcess extends SimuComSimProcess {
19 
20        protected Context ctx;
21        private ISimProcess myParent;
22        protected String assemblyContextID;
23        private boolean isAsync;
24        private boolean isTerminated = false;
25        private IRegionBasedGarbageCollector<RequestContext> blackboardGarbageCollector;
26 
27        private static Logger logger = Logger.getLogger(ForkedBehaviourProcess.class.getName());
28 
29        public ForkedBehaviourProcess(Context myContext, String assemblyContextID, boolean isAsync) {
30                super(myContext.getModel(), "Forked Behaviour", myContext.getThread().getRequestContext());
31                
32                // use the session id from the parent process
33                this.currentSessionId = myContext.getThread().getCurrentSessionId();
34                
35                this.ctx = new ForkContext(myContext, this);
36         
37                this.myParent = myContext.getThread();
38                this.assemblyContextID = assemblyContextID;
39                this.isAsync = isAsync;
40        this.blackboardGarbageCollector = myContext.getModel().getProbeSpecContext().getBlackboardGarbageCollector();
41        }
42 
43        @Override
44        protected void internalLifeCycle() {
45                blackboardGarbageCollector.enterRegion(getRequestContext().rootContext());
46                executeBehaviour();
47                blackboardGarbageCollector.leaveRegion(getRequestContext().rootContext());
48                this.isTerminated = true;
49 
50                // if this has been synchronous call of the behaviour and the parent has
51                // not yet terminated (which may happen under some wired conditions) and
52                // the simulation is still running, we can think about triggering the
53                // parent again.
54                if (!isAsync && !myParent.isTerminated() && simulationIsRunning())
55                        myParent.scheduleAt(0);
56                else
57                        logger.debug("Asynch behaviour finished at simtime " + getModel().getSimulationControl().getCurrentSimulationTime());
58        }
59 
60        private boolean simulationIsRunning() {
61                return this.ctx.getModel().getSimulationControl().isRunning();
62        }
63 
64        /**
65         * Template method filled by the generate with the parallel behaviour
66         * specified in the PCM's fork action
67         */
68        protected abstract void executeBehaviour();
69 
70        public boolean isAsync() {
71                return isAsync;
72        }
73 
74        /*
75         * (non-Javadoc)
76         * 
77         * @see
78         * de.uka.ipd.sdq.simulation.abstractsimengine.SimProcess#isTerminated
79         * ()
80         */
81        @Override
82        public boolean isTerminated() {
83                return this.isTerminated;
84        }
85 
86}

[all classes][de.uka.ipd.sdq.simucomframework.fork]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov