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
3fd23830
Commit
3fd23830
authored
12 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Use an unbounded executor for DB tasks, which may depend on each other.
parent
f076a65e
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
briar-core/src/net/sf/briar/db/DatabaseModule.java
+12
-12
12 additions, 12 deletions
briar-core/src/net/sf/briar/db/DatabaseModule.java
with
12 additions
and
12 deletions
briar-core/src/net/sf/briar/db/DatabaseModule.java
+
12
−
12
View file @
3fd23830
package
net.sf.briar.db
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
MILLISECONDS
;
import
java.sql.Connection
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
net.sf.briar.api.clock.Clock
;
import
net.sf.briar.api.clock.SystemClock
;
...
...
@@ -9,7 +14,6 @@ import net.sf.briar.api.db.DatabaseComponent;
import
net.sf.briar.api.db.DatabaseConfig
;
import
net.sf.briar.api.db.DatabaseExecutor
;
import
net.sf.briar.api.lifecycle.ShutdownManager
;
import
net.sf.briar.util.BoundedExecutor
;
import
com.google.inject.AbstractModule
;
import
com.google.inject.Provides
;
...
...
@@ -17,27 +21,23 @@ import com.google.inject.Singleton;
public
class
DatabaseModule
extends
AbstractModule
{
// FIXME: Determine suitable values for these constants empirically
/**
* The maximum number of database tasks that can be queued for execution
* before submitting another task will block.
*/
private
static
final
int
MAX_QUEUED_DB_TASKS
=
1000
;
/** The minimum number of database threads to keep in the pool. */
private
static
final
int
MIN_DB_THREADS
=
1
;
/** The maximum number of database threads. */
private
static
final
int
MAX_DB_THREADS
=
10
;
/** The time in milliseconds to keep unused database threads alive. */
private
static
final
int
DB_KEEPALIVE
=
60
*
1000
;
@Override
protected
void
configure
()
{
bind
(
DatabaseCleaner
.
class
).
to
(
DatabaseCleanerImpl
.
class
);
// The executor is bounded, so tasks must be independent and short-lived
// Database tasks may depend on each other, so use an unbounded queue
BlockingQueue
<
Runnable
>
queue
=
new
LinkedBlockingQueue
<
Runnable
>();
bind
(
Executor
.
class
).
annotatedWith
(
DatabaseExecutor
.
class
).
toInstance
(
new
BoundedExecutor
(
MAX_QUEUED_DB_TASK
S
,
M
IN
_DB_THREADS
,
MAX_DB_THREADS
));
new
ThreadPoolExecutor
(
MIN_DB_THREAD
S
,
M
AX
_DB_THREADS
,
DB_KEEPALIVE
,
MILLISECONDS
,
queue
));
}
@Provides
...
...
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