Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor 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
Savage
NetworkedGraphicsMV3500
Commits
8fddd5b4
Commit
8fddd5b4
authored
3 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
further assertiveness shutting down threads
parent
905c14a8
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/edu/nps/moves/dis7/utilities/DisThreadedNetworkInterface.java
+19
-1
19 additions, 1 deletion
...nps/moves/dis7/utilities/DisThreadedNetworkInterface.java
with
19 additions
and
1 deletion
src/edu/nps/moves/dis7/utilities/DisThreadedNetworkInterface.java
+
19
−
1
View file @
8fddd5b4
...
...
@@ -108,6 +108,7 @@ public class DisThreadedNetworkInterface
private
String
disAddress
;
private
int
disPort
;
private
boolean
killed
=
false
;
private
int
killCounter
=
0
;
private
InetAddress
inetAddress
;
private
InetSocketAddress
inetSocket
;
...
...
@@ -404,6 +405,7 @@ public class DisThreadedNetworkInterface
message
+=
", size "
+
nextPdu
.
getMarshalledSize
()
+
" bytes)"
;
System
.
out
.
println
(
message
);
System
.
out
.
flush
();
System
.
err
.
flush
();
}
toListeners
(
nextPdu
);
}
...
...
@@ -426,6 +428,10 @@ public class DisThreadedNetworkInterface
close
();
}
}
if
(
killed
)
close
();
// retry now that threads are killed
System
.
err
.
flush
();
System
.
out
.
flush
();
};
private
final
Runnable
senderThreadRunnable
=
()
->
{
...
...
@@ -464,6 +470,7 @@ public class DisThreadedNetworkInterface
message
+=
", size "
+
nextPdu
.
getMarshalledSize
()
+
" bytes)"
;
System
.
out
.
println
(
message
);
System
.
out
.
flush
();
System
.
err
.
flush
();
}
dos
.
flush
();
// immediately force pdu write
baos
.
reset
();
// prepare for next send
...
...
@@ -482,8 +489,13 @@ public class DisThreadedNetworkInterface
pdus2send
.
clear
();
dos
.
close
();
this
.
close
();
}
catch
(
IOException
e
)
{}
// shutting down, no need to report exception
if
(
killed
)
close
();
// retry now that threads are killed
System
.
err
.
flush
();
System
.
out
.
flush
();
};
private
void
toListeners
(
Pdu
pdu
)
...
...
@@ -533,7 +545,12 @@ public class DisThreadedNetworkInterface
* Synchronized to prevent interleaved invocation. */
public
synchronized
void
close
()
{
setKillSentinel
();
if
(!
killed
||
((
killCounter
>
0
)
&&
(
killCounter
<
2
)))
{
killCounter
++;
// repeat for all threads
setKillSentinel
();
return
;
// allow network operations to finish, then killed threads are expected to reenter here
}
try
{
...
...
@@ -572,6 +589,7 @@ public class DisThreadedNetworkInterface
}
}
datagramSocket
=
null
;
// make sure
killCounter
=
0
;
// prepare for next run
System
.
err
.
flush
();
// ensure all output sent
System
.
out
.
flush
();
// ensure all output sent
}
...
...
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