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
acc3b2a9
Commit
acc3b2a9
authored
9 years ago
by
Nelson Tavares de Sousa
Browse files
Options
Downloads
Patches
Plain Diff
some clean-up
parent
90194686
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/teetime/framework/ThreadService.java
+58
-58
58 additions, 58 deletions
src/main/java/teetime/framework/ThreadService.java
with
58 additions
and
58 deletions
src/main/java/teetime/framework/ThreadService.java
+
58
−
58
View file @
acc3b2a9
...
...
@@ -43,10 +43,6 @@ class ThreadService extends AbstractService<ThreadService> {
}
SignalingCounter
getRunnableCounter
()
{
return
runnableCounter
;
}
private
final
Collection
<
ThreadThrowableContainer
>
exceptions
=
new
ConcurrentLinkedQueue
<
ThreadThrowableContainer
>();
private
final
List
<
RunnableProducerStage
>
producerRunnables
=
new
LinkedList
<
RunnableProducerStage
>();
...
...
@@ -75,6 +71,62 @@ class ThreadService extends AbstractService<ThreadService> {
onStart
();
}
@Override
void
onStart
()
{
startThreads
(
this
.
consumerThreads
);
startThreads
(
this
.
finiteProducerThreads
);
startThreads
(
this
.
infiniteProducerThreads
);
sendInitializingSignal
();
}
@Override
void
onExecute
()
{
sendStartingSignal
();
}
@Override
void
onTerminate
()
{
for
(
Stage
stage
:
threadableStages
.
keySet
())
{
stage
.
terminate
();
}
}
@Override
void
onFinish
()
{
try
{
runnableCounter
.
waitFor
(
0
);
// LOGGER.debug("Waiting for finiteProducerThreads");
// for (Thread thread : this.finiteProducerThreads) {
// thread.join();
// }
//
// LOGGER.debug("Waiting for consumerThreads");
// for (Thread thread : this.consumerThreads) {
// thread.join();
// }
}
catch
(
InterruptedException
e
)
{
LOGGER
.
error
(
"Execution has stopped unexpectedly"
,
e
);
for
(
Thread
thread
:
this
.
finiteProducerThreads
)
{
thread
.
interrupt
();
}
for
(
Thread
thread
:
this
.
consumerThreads
)
{
thread
.
interrupt
();
}
}
LOGGER
.
debug
(
"Interrupting infiniteProducerThreads..."
);
for
(
Thread
thread
:
this
.
infiniteProducerThreads
)
{
thread
.
interrupt
();
}
if
(!
exceptions
.
isEmpty
())
{
throw
new
ExecutionException
(
exceptions
);
}
}
private
void
initializeIntraStages
(
final
Set
<
Stage
>
intraStages
,
final
Thread
thread
,
final
AbstractExceptionListener
newListener
)
{
for
(
Stage
intraStage
:
intraStages
)
{
intraStage
.
setOwningThread
(
thread
);
...
...
@@ -135,55 +187,6 @@ class ThreadService extends AbstractService<ThreadService> {
}
}
@Override
void
onFinish
()
{
try
{
runnableCounter
.
waitFor
(
0
);
// LOGGER.debug("Waiting for finiteProducerThreads");
// for (Thread thread : this.finiteProducerThreads) {
// thread.join();
// }
//
// LOGGER.debug("Waiting for consumerThreads");
// for (Thread thread : this.consumerThreads) {
// thread.join();
// }
}
catch
(
InterruptedException
e
)
{
LOGGER
.
error
(
"Execution has stopped unexpectedly"
,
e
);
for
(
Thread
thread
:
this
.
finiteProducerThreads
)
{
thread
.
interrupt
();
}
for
(
Thread
thread
:
this
.
consumerThreads
)
{
thread
.
interrupt
();
}
}
LOGGER
.
debug
(
"Interrupting infiniteProducerThreads..."
);
for
(
Thread
thread
:
this
.
infiniteProducerThreads
)
{
thread
.
interrupt
();
}
if
(!
exceptions
.
isEmpty
())
{
throw
new
ExecutionException
(
exceptions
);
}
}
@Override
void
onExecute
()
{
sendStartingSignal
();
}
@Override
void
onStart
()
{
startThreads
(
this
.
consumerThreads
);
startThreads
(
this
.
finiteProducerThreads
);
startThreads
(
this
.
infiniteProducerThreads
);
sendInitializingSignal
();
}
private
void
startThreads
(
final
Iterable
<
Thread
>
threads
)
{
for
(
Thread
thread
:
threads
)
{
thread
.
start
();
...
...
@@ -216,11 +219,8 @@ class ThreadService extends AbstractService<ThreadService> {
source
.
setThreadableStages
(
this
.
getThreadableStages
());
}
@Override
void
onTerminate
()
{
for
(
Stage
stage
:
threadableStages
.
keySet
())
{
stage
.
terminate
();
}
SignalingCounter
getRunnableCounter
()
{
return
runnableCounter
;
}
}
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