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
6a727ed2
Commit
6a727ed2
authored
10 years ago
by
Nelson Tavares de Sousa
Browse files
Options
Downloads
Patches
Plain Diff
refactored EveryXthPrinter
parent
b8558b2d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/teetime/stage/io/EveryXthPrinter.java
+18
-13
18 additions, 13 deletions
src/main/java/teetime/stage/io/EveryXthPrinter.java
with
18 additions
and
13 deletions
src/main/java/teetime/stage/io/EveryXthPrinter.java
+
18
−
13
View file @
6a727ed2
...
...
@@ -15,43 +15,38 @@
*/
package
teetime.stage.io
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
teetime.framework.CompositeStage
;
import
teetime.framework.InputPort
;
import
teetime.framework.OutputPort
;
import
teetime.framework.Stage
;
import
teetime.framework.TerminationStrategy
;
import
teetime.framework.pipe.IPipeFactory
;
import
teetime.framework.pipe.PipeFactoryRegistry
;
import
teetime.framework.pipe.PipeFactoryRegistry.PipeOrdering
;
import
teetime.framework.pipe.PipeFactoryRegistry.ThreadCommunication
;
import
teetime.framework.signal.ISignal
;
import
teetime.framework.validation.InvalidPortConnection
;
import
teetime.stage.EveryXthStage
;
import
teetime.stage.basic.distributor.CopyByReferenceStrategy
;
import
teetime.stage.basic.distributor.Distributor
;
public
final
class
EveryXthPrinter
<
T
>
extends
Stage
{
public
final
class
EveryXthPrinter
<
T
>
extends
Composite
Stage
{
private
final
Distributor
<
T
>
distributor
;
private
final
List
<
Stage
>
lastStages
=
new
ArrayList
<
Stage
>();
public
EveryXthPrinter
(
final
int
threshold
)
{
distributor
=
new
Distributor
<
T
>();
EveryXthStage
<
T
>
everyXthStage
=
new
EveryXthStage
<
T
>(
threshold
);
Printer
<
Integer
>
printer
=
new
Printer
<
Integer
>();
IPipeFactory
pipeFactory
=
PipeFactoryRegistry
.
INSTANCE
.
getPipeFactory
(
ThreadCommunication
.
INTRA
,
PipeOrdering
.
ARBITRARY
,
false
);
pipeFactory
.
create
(
distributor
.
getNewOutputPort
(),
everyXthStage
.
getInputPort
());
pipeFactory
.
create
(
everyXthStage
.
getOutputPort
(),
printer
.
getInputPort
());
connectStages
(
distributor
.
getNewOutputPort
(),
everyXthStage
.
getInputPort
());
connectStages
(
everyXthStage
.
getOutputPort
(),
printer
.
getInputPort
());
lastStages
.
add
(
printer
);
distributor
.
setStrategy
(
new
CopyByReferenceStrategy
());
}
@Override
protected
void
executeWithPorts
()
{
distributor
.
executeWithPorts
();
}
@Override
public
void
validateOutputPorts
(
final
List
<
InvalidPortConnection
>
invalidPortConnections
)
{
distributor
.
validateOutputPorts
(
invalidPortConnections
);
...
...
@@ -95,4 +90,14 @@ public final class EveryXthPrinter<T> extends Stage {
return
distributor
.
isStarted
();
}
@Override
protected
Stage
getFirstStage
()
{
return
distributor
;
}
@Override
protected
Collection
<?
extends
Stage
>
getLastStages
()
{
return
lastStages
;
}
}
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