// the execution which will continue
PvmExecutionImpl propagatingExecution = execution;
// the activity which is to be executed concurrently
ActivityImpl concurrentActivity = execution.getNextActivity();
ScopeImpl concurrencyScope = concurrentActivity.getScope();
if(isLeaf(execution)) {
if(execution.getActivity() != null
&& execution.isScope()
&& !(execution.getActivity()).isScope()
&& concurrencyScope == execution.getActivity().getParent()
) {
// Expand tree (1):
//
// ... ...
// | |
// +------+ +-------+ s=tt
// | e | => | e | cc=ff
// +------+ +-------+
// s=tt ^
// cc=ff / \
// / \
// / \ Both:
// +-------+ +--------+ s=ff
// | CCE-1 | | PPE | cc=tt
// +-------+ +--------+
//
// 1) create new concurrent execution (CCE-1) replacing the the active scope execution (e)
PvmExecutionImpl replacingExecution = execution.createExecution();
replacingExecution.replace(execution); // only copy tasks(?)
replacingExecution.setActivity(execution.getActivity());
replacingExecution.setActive(execution.isActive());
replacingExecution.setScope(false);
replacingExecution.setConcurrent(true);
execution.setActive(false);
execution.setActivity(null);
// 2) create new concurrent execution (PPE) for new activity instance
propagatingExecution = createConcurrentExecution(execution, concurrentActivity);
} else {
// Case (1): Expand tree and set execution to concurrent:
//
// ... ...
// | |
// +------+ s=tt +-------+ s=tt
// | p | cc=ff => | p | cc=ff
// +------+ +-------+
// | ^
// | / \
// | / \
// | / \ Both:
// +------+ s=tt +-------+ +--------+ s=ff
// | e | cc=ff | e | | PPE | cc=tt
// +------+ +-------+ +--------+
//
// Case (2): Add to existing concurrency tree rooting at parent of parent
//
//
// ... ...
// | |
// +-------+ s=tt +--------+ s=tt
// | pp | cc=ff | pp | cc=ff
// +-------+ +--------+
// ^ ^ ^
// / \ => / \ \
// / \ / \ \
// / \ all: / \ \ all:
// +--------+ .... s=ff +--------+ .... +-------+ s=ff
// | parent | cc=tt | parent | | PPE | cc=tt
// +--------+ +--------+ +-------+
// | |
// +-------+ s=tt +-------+ s=tt
// | e | cc=ff | e | cc=ff
// +-------+ +-------+
//
// Case (1)
PvmExecutionImpl parent = execution.getParent();
if (!parent.isConcurrent()) {
// mark execution (e) concurrent
execution.setConcurrent(true);
} else {
// Case (2)
parent = parent.getParent();
}
propagatingExecution = createConcurrentExecution(parent, concurrentActivity);
}
} else {
List<? extends PvmExecutionImpl> childExecutions = execution.getExecutions();
if(childExecutions.size() == 1
&& execution.getActivity() == null
&& !execution.isActive()) {
// Add new child execution and set concurrent flag to true
// for already existing child execution
//
// ... ...
// | |
// +------+ s=tt +-------+ s=tt
// | e | cc=ff => | e | cc=ff
// +------+ +-------+
// | ^
// | / \
// | / \
// | / \ Both:
// +------+ s=tt +-------+ +--------+ s=ff
// |child | cc=ff | child | | PPE | cc=tt
// +------+ +-------+ +--------+
//
// 1) mark existing child concurrent
PvmExecutionImpl existingChild = childExecutions.get(0);
existingChild.setConcurrent(true);
// 2) create new concurrent execution (PPE) for new activity instance
propagatingExecution = createConcurrentExecution(execution, concurrentActivity);
} else { /* execution.getExecutions().size() > 1 */
// Add to existing concurrency tree:
//
// Case (1)
// +-------+ s=tt +-------+ s=tt
// | e | cc=ff | e | cc=ff
// +-------+ +-------+
// ^ ^ ^
// / \ => / \ \
// / \ / \ \
// / \ all: / \ \
// +-------+ .... s=? +-------+ ... +-------+ s=ff
// | | cc=tt | | | PPE | cc=tt
// +-------+ +-------+ +-------+
//
// Case (2)
//
// ... ...
// | | s=tt
// +-------+ s=tt +-------+ cc=ff
// | parent| cc=ff | parent|<------------+
// +-------+ +-------+ |
// | | |
// +-------+ s=tt +-------+ s=tt +-------+ s=ff
// | e | cc=? | e | cc=tt | PPE | cc=tt
// +-------+ +-------+ +-------+
// ^ ^
// / \ => / \
// / \ / \
// / \ all: / \ all:
// +-------+ .... s=? +-------+ ... s=?
// | | cc=tt | | cc=tt
// +-------+ +-------+
//
// Case (3)
//
// ... ...
// | s=tt | s=tt
// +-------+ cc=? +-------+ cc=?
// | pp |<-----------+ | pp |<---------------------------+
// +-------+ | +-------+ | |
// | | all: | | all: |
// | s=tt | s=? | s=tt | s=? |
// +-------+ cc=tt ... cc=tt +-------+ cc=tt ... cc=tt +-------+ s=ff
// | parent| | parent| | PPE | cc=tt
// +-------+ +-------+ +-------+
// | |
// +-------+ s=tt +-------+ s=tt
// | e | cc=? | e | cc=?
// +-------+ +-------+
// ^ ^
// / \ => / \
// / \ / \
// / \ all: / \ all:
// +-------+ .... s=? +-------+ ... s=?
// | | cc=tt | | cc=tt
// +-------+ +-------+
//
//
// Case (1)
PvmExecutionImpl concurrentRoot = execution;
ScopeImpl parentScope = concurrentActivity.getParent();
if(parentScope instanceof ActivityImpl) {
ActivityImpl parentActivity = (ActivityImpl) parentScope;
if (execution.getActivity() != null || execution.isActive()) {
if(parentActivity.isScope()) {
// Case (2)
concurrentRoot = execution.getParent();
if (!concurrentRoot.isConcurrent()) {
execution.setConcurrent(true);