Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TeeTime-Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nelson Tavares de Sousa
TeeTime-Framework
Commits
4b5f595c
Commit
4b5f595c
authored
9 years ago
by
Nelson Tavares de Sousa
Browse files
Options
Downloads
Patches
Plain Diff
refactoring
parent
2f2be3fd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/teetime/framework/A2InvalidThreadAssignmentCheck.java
+7
-10
7 additions, 10 deletions
...ava/teetime/framework/A2InvalidThreadAssignmentCheck.java
src/main/java/teetime/framework/A3PipeInstantiation.java
+14
-13
14 additions, 13 deletions
src/main/java/teetime/framework/A3PipeInstantiation.java
with
21 additions
and
23 deletions
src/main/java/teetime/framework/A2InvalidThreadAssignmentCheck.java
+
7
−
10
View file @
4b5f595c
...
...
@@ -37,17 +37,18 @@ public class A2InvalidThreadAssignmentCheck {
this
.
threadableStages
=
threadableStages
;
}
@SuppressWarnings
(
"PMD.DataflowAnomalyAnalysis"
)
public
void
check
()
{
int
color
=
DEFAULT_COLOR
;
ObjectIntMap
<
AbstractStage
>
colors
=
new
ObjectIntHashMap
<
AbstractStage
>();
ThreadPainter
threadPainter
=
new
ThreadPainter
();
Traverser
traverser
=
new
Traverser
(
threadPainter
);
for
(
AbstractStage
threadableStage
:
threadableStages
)
{
color
++;
colors
.
put
(
threadableStage
,
color
);
threadPainter
.
reset
(
colors
,
color
,
threadableStages
);
Traverser
traverser
=
new
Traverser
(
threadPainter
);
traverser
.
traverse
(
threadableStage
);
}
}
...
...
@@ -77,17 +78,13 @@ public class A2InvalidThreadAssignmentCheck {
int
targetColor
=
colors
.
containsKey
(
targetStage
)
?
colors
.
get
(
targetStage
)
:
DEFAULT_COLOR
;
if
(
threadableStages
.
contains
(
targetStage
)
&&
targetColor
!=
color
)
{
// do nothing
}
else
{
if
(
colors
.
containsKey
(
targetStage
))
{
if
(
colors
.
get
(
targetStage
)
!=
color
)
{
throw
new
IllegalStateException
(
"1001 - Crossing threads in "
+
targetStage
.
getId
());
// One stage is connected to a stage of another thread
// (but not its "headstage")
}
if
(!
threadableStages
.
contains
(
targetStage
)
||
targetColor
==
color
)
{
if
(
colors
.
containsKey
(
targetStage
)
&&
colors
.
get
(
targetStage
)
!=
color
)
{
throw
new
IllegalStateException
(
"1001 - Crossing threads in "
+
targetStage
.
getId
());
// One stage is connected to a stage of another thread
// (but not its "headstage")
}
colors
.
put
(
targetStage
,
color
);
return
VisitorBehavior
.
CONTINUE
;
return
VisitorBehavior
.
CONTINUE
;
// NOPMD makes it clearer
}
return
VisitorBehavior
.
STOP
;
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/teetime/framework/A3PipeInstantiation.java
+
14
−
13
View file @
4b5f595c
...
...
@@ -47,7 +47,7 @@ class A3PipeInstantiation implements ITraverserVisitor {
public
VisitorBehavior
visit
(
final
AbstractPort
<?>
port
)
{
IPipe
<?>
pipe
=
port
.
getPipe
();
if
(
visitedPipes
.
contains
(
pipe
))
{
return
VisitorBehavior
.
STOP
;
return
VisitorBehavior
.
STOP
;
// NOPMD two returns are better
}
visitedPipes
.
add
(
pipe
);
...
...
@@ -64,25 +64,26 @@ class A3PipeInstantiation implements ITraverserVisitor {
Thread
sourceStageThread
=
pipe
.
getSourcePort
().
getOwningStage
().
getOwningThread
();
Thread
targetStageThread
=
pipe
.
getTargetPort
().
getOwningStage
().
getOwningThread
();
if
(
targetStageThread
!=
null
&&
sourceStageThread
!=
targetStageThread
)
{
if
(
targetStageThread
==
null
||
sourceStageThread
==
targetStageThread
)
{
// NOPMD .equals() can't be used here
// normal or reflexive pipe => intra
new
UnsynchedPipe
<
T
>(
pipe
.
getSourcePort
(),
pipe
.
getTargetPort
());
if
(
LOGGER
.
isDebugEnabled
())
{
LOGGER
.
debug
(
"Connected (unsynch) "
+
pipe
.
getSourcePort
()
+
" and "
+
pipe
.
getTargetPort
());
}
}
else
{
// inter
if
(
pipe
.
capacity
()
!
=
0
)
{
new
B
oundedSynchedPipe
<
T
>(
pipe
.
getSourcePort
(),
pipe
.
getTargetPort
()
,
pipe
.
capacity
()
);
if
(
pipe
.
capacity
()
=
=
0
)
{
new
Unb
oundedSynchedPipe
<
T
>(
pipe
.
getSourcePort
(),
pipe
.
getTargetPort
());
if
(
LOGGER
.
isDebugEnabled
())
{
LOGGER
.
debug
(
"Connected (bounded) "
+
pipe
.
getSourcePort
()
+
" and "
+
pipe
.
getTargetPort
());
LOGGER
.
debug
(
"Connected (
un
bounded) "
+
pipe
.
getSourcePort
()
+
" and "
+
pipe
.
getTargetPort
());
}
}
else
{
new
Unb
oundedSynchedPipe
<
T
>(
pipe
.
getSourcePort
(),
pipe
.
getTargetPort
());
new
B
oundedSynchedPipe
<
T
>(
pipe
.
getSourcePort
(),
pipe
.
getTargetPort
()
,
pipe
.
capacity
()
);
if
(
LOGGER
.
isDebugEnabled
())
{
LOGGER
.
debug
(
"Connected (
un
bounded) "
+
pipe
.
getSourcePort
()
+
" and "
+
pipe
.
getTargetPort
());
LOGGER
.
debug
(
"Connected (bounded) "
+
pipe
.
getSourcePort
()
+
" and "
+
pipe
.
getTargetPort
());
}
}
}
else
{
// normal or reflexive pipe => intra
new
UnsynchedPipe
<
T
>(
pipe
.
getSourcePort
(),
pipe
.
getTargetPort
());
if
(
LOGGER
.
isDebugEnabled
())
{
LOGGER
.
debug
(
"Connected (unsynch) "
+
pipe
.
getSourcePort
()
+
" and "
+
pipe
.
getTargetPort
());
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment