Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
e5d15d42
Commit
e5d15d42
authored
12 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Use an executor for the reliability layer's writer task.
parent
1e1a226f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java
+4
-2
4 additions, 2 deletions
briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java
briar-core/src/net/sf/briar/plugins/modem/ReliabilityLayer.java
+8
-8
8 additions, 8 deletions
...core/src/net/sf/briar/plugins/modem/ReliabilityLayer.java
with
12 additions
and
10 deletions
briar-core/src/net/sf/briar/plugins/modem/ModemImpl.java
+
4
−
2
View file @
e5d15d42
...
...
@@ -170,7 +170,8 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
return
false
;
}
try
{
ReliabilityLayer
reliabilityLayer
=
new
ReliabilityLayer
(
this
);
ReliabilityLayer
reliabilityLayer
=
new
ReliabilityLayer
(
executor
,
this
);
synchronized
(
this
)
{
if
(!
initialised
)
{
if
(
LOG
.
isLoggable
(
INFO
))
...
...
@@ -348,7 +349,8 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
return
;
}
try
{
ReliabilityLayer
reliabilityLayer
=
new
ReliabilityLayer
(
this
);
ReliabilityLayer
reliabilityLayer
=
new
ReliabilityLayer
(
executor
,
this
);
synchronized
(
this
)
{
if
(!
initialised
)
{
if
(
LOG
.
isLoggable
(
INFO
))
...
...
This diff is collapsed.
Click to expand it.
briar-core/src/net/sf/briar/plugins/modem/ReliabilityLayer.java
+
8
−
8
View file @
e5d15d42
...
...
@@ -7,6 +7,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.logging.Logger
;
...
...
@@ -17,6 +18,7 @@ class ReliabilityLayer implements ReadHandler, WriteHandler {
private
static
final
Logger
LOG
=
Logger
.
getLogger
(
ReliabilityLayer
.
class
.
getName
());
private
final
Executor
executor
;
private
final
WriteHandler
writeHandler
;
private
final
BlockingQueue
<
byte
[]>
writes
;
...
...
@@ -24,10 +26,10 @@ class ReliabilityLayer implements ReadHandler, WriteHandler {
private
volatile
SlipDecoder
decoder
=
null
;
private
volatile
ReceiverInputStream
inputStream
=
null
;
private
volatile
SenderOutputStream
outputStream
=
null
;
private
volatile
Thread
writer
=
null
;
private
volatile
boolean
running
=
false
;
ReliabilityLayer
(
WriteHandler
writeHandler
)
{
ReliabilityLayer
(
Executor
executor
,
WriteHandler
writeHandler
)
{
this
.
executor
=
executor
;
this
.
writeHandler
=
writeHandler
;
writes
=
new
LinkedBlockingQueue
<
byte
[]>();
}
...
...
@@ -39,8 +41,8 @@ class ReliabilityLayer implements ReadHandler, WriteHandler {
decoder
=
new
SlipDecoder
(
receiver
);
inputStream
=
new
ReceiverInputStream
(
receiver
);
outputStream
=
new
SenderOutputStream
(
sender
);
writer
=
new
Thread
(
"ReliabilityLayer"
)
{
@Override
running
=
true
;
executor
.
execute
(
new
Runnable
()
{
public
void
run
()
{
long
now
=
System
.
currentTimeMillis
();
long
next
=
now
+
TICK_INTERVAL
;
...
...
@@ -61,7 +63,7 @@ class ReliabilityLayer implements ReadHandler, WriteHandler {
}
}
catch
(
InterruptedException
e
)
{
if
(
LOG
.
isLoggable
(
WARNING
))
LOG
.
warning
(
"Interrupted while w
r
iting"
);
LOG
.
warning
(
"Interrupted while w
a
iting
to write
"
);
Thread
.
currentThread
().
interrupt
();
running
=
false
;
}
catch
(
IOException
e
)
{
...
...
@@ -70,9 +72,7 @@ class ReliabilityLayer implements ReadHandler, WriteHandler {
running
=
false
;
}
}
};
running
=
true
;
writer
.
start
();
});
}
InputStream
getInputStream
()
{
...
...
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