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
90e32ac9
Commit
90e32ac9
authored
13 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
AtomicBoolean is not needed.
parent
dea77b22
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
components/net/sf/briar/db/DatabaseCleanerImpl.java
+8
-9
8 additions, 9 deletions
components/net/sf/briar/db/DatabaseCleanerImpl.java
with
8 additions
and
9 deletions
components/net/sf/briar/db/DatabaseCleanerImpl.java
+
8
−
9
View file @
90e32ac9
package
net.sf.briar.db
;
import
java.util.concurrent.atomic.AtomicBoolean
;
class
DatabaseCleanerImpl
implements
DatabaseCleaner
,
Runnable
{
private
final
AtomicBoolean
stopped
=
new
AtomicBoolean
(
false
);
private
final
Object
lock
=
new
Object
(
);
private
final
Thread
cleanerThread
=
new
Thread
(
this
);
private
volatile
Callback
callback
;
private
volatile
long
msBetweenSweeps
;
private
volatile
boolean
stopped
=
false
;
// Locking: lock
public
void
startCleaning
(
Callback
callback
,
long
msBetweenSweeps
)
{
this
.
callback
=
callback
;
...
...
@@ -17,10 +16,10 @@ class DatabaseCleanerImpl implements DatabaseCleaner, Runnable {
}
public
void
stopCleaning
()
{
stopped
.
set
(
true
);
// If the cleaner thread is waiting, wake it up
synchronized
(
stopped
)
{
stopped
.
notifyAll
();
synchronized
(
lock
)
{
stopped
=
true
;
lock
.
notifyAll
();
}
try
{
cleanerThread
.
join
();
...
...
@@ -33,10 +32,10 @@ class DatabaseCleanerImpl implements DatabaseCleaner, Runnable {
if
(
callback
.
shouldCheckFreeSpace
())
{
callback
.
checkFreeSpaceAndClean
();
}
else
{
synchronized
(
stopped
)
{
if
(
stopped
.
get
()
)
break
;
synchronized
(
lock
)
{
if
(
stopped
)
break
;
try
{
stopped
.
wait
(
msBetweenSweeps
);
lock
.
wait
(
msBetweenSweeps
);
}
catch
(
InterruptedException
ignored
)
{}
}
}
...
...
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