1 | package de.uka.ipd.sdq.scheduler.events; |
2 | |
3 | import org.apache.log4j.Logger; |
4 | |
5 | import de.uka.ipd.sdq.scheduler.SchedulerModel; |
6 | import de.uka.ipd.sdq.scheduler.processes.IActiveProcess; |
7 | import de.uka.ipd.sdq.scheduler.strategy.IScheduler; |
8 | import de.uka.ipd.sdq.simulation.abstractsimengine.AbstractSimEventDelegator; |
9 | |
10 | /** |
11 | * Event to proceed the activity of a process. This event requires, that at the |
12 | * time it happens, the current demand of the process is zero, thus all former |
13 | * actions of the process have been finished. |
14 | * |
15 | * This event can either continue the process directly or execute a delayed |
16 | * action of the process. Delayed actions are activities that are executed by |
17 | * the scheduler (e.g. some housekeeping or asking for access to a passive |
18 | * resource) but require the process to be running. DelayedActions have priority |
19 | * of the proceeding of the process as they have to be finished in oder to |
20 | * continue process execution. |
21 | * |
22 | * @author jens |
23 | * |
24 | */ |
25 | public class ProceedEvent extends AbstractSimEventDelegator<IActiveProcess> { |
26 | |
27 | private IDelayedAction action; |
28 | protected IScheduler scheduler; |
29 | static Logger logger = Logger.getLogger(ProceedEvent.class); |
30 | |
31 | public ProceedEvent(SchedulerModel model) { |
32 | super(model, "ProceedEvent"); |
33 | this.action = null; |
34 | } |
35 | |
36 | public void setDelayedAction(IDelayedAction action) { |
37 | this.action = action; |
38 | } |
39 | |
40 | @Override |
41 | public void eventRoutine(IActiveProcess process) { |
42 | logger.debug("Proceed Event handler triggered"); |
43 | process.toNow(); |
44 | if (action != null) { |
45 | // once the action has been successfully executed it is removed. |
46 | if (action.perform()) |
47 | action = null; |
48 | } else { |
49 | process.getSchedulableProcess().activate(); |
50 | } |
51 | } |
52 | |
53 | public void setScheduler(IScheduler scheduler) { |
54 | this.scheduler = scheduler; |
55 | } |
56 | |
57 | } |