1 | package de.uka.ipd.sdq.simucomframework.fork; |
2 | |
3 | import de.uka.ipd.sdq.simucomframework.Context; |
4 | import de.uka.ipd.sdq.simucomframework.SimuComSimProcess; |
5 | import de.uka.ipd.sdq.simucomframework.resources.AbstractSimulatedResourceContainer; |
6 | import de.uka.ipd.sdq.simucomframework.variables.stackframe.SimulatedStack; |
7 | |
8 | /** |
9 | * Context for forked behaviours |
10 | * @author Steffen Becker |
11 | * |
12 | */ |
13 | public class ForkContext extends Context { |
14 | |
15 | private Context parentContext; |
16 | |
17 | /** |
18 | * Constructor of the parallel process |
19 | * @param parentContext The current context of the parent thread. |
20 | * Used to evaluate variables in the parallel process |
21 | * @param parent The parent process |
22 | */ |
23 | public ForkContext(Context parentContext, SimuComSimProcess parent) { |
24 | super(parentContext.getModel()); |
25 | this.setSimProcess(parent); |
26 | this.parentContext = parentContext; |
27 | this.stack = new SimulatedStack<Object>(); |
28 | |
29 | // Run this thread with a copy of the parents stackframe |
30 | // Likely subject to change in later PCM versions |
31 | this.stack.pushStackFrame(parentContext.getStack().currentStackFrame().copyFrame()); |
32 | } |
33 | |
34 | /** |
35 | * |
36 | */ |
37 | private static final long serialVersionUID = 6701742993106975705L; |
38 | |
39 | @Override |
40 | public AbstractSimulatedResourceContainer findResource(String assemblyContextID) { |
41 | // Use my parents allocation information to do my look ups |
42 | return parentContext.findResource(assemblyContextID); |
43 | } |
44 | |
45 | public Context getParentContext() { |
46 | return parentContext; |
47 | } |
48 | |
49 | @Override |
50 | protected void initialiseAssemblyContextLookup() { |
51 | // Emtpy as we use our parents allocation lookup |
52 | } |
53 | |
54 | } |