Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parity-test-sync
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
parity
parity-test-sync
Commits
53afb8d2
Commit
53afb8d2
authored
8 years ago
by
asynchronous rob
Browse files
Options
Downloads
Patches
Plain Diff
queue: park directly instead of through condvar
parent
133796b7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ethcore/src/verification/queue/mod.rs
+10
-11
10 additions, 11 deletions
ethcore/src/verification/queue/mod.rs
with
10 additions
and
11 deletions
ethcore/src/verification/queue/mod.rs
+
10
−
11
View file @
53afb8d2
...
...
@@ -66,20 +66,20 @@ impl Default for Config {
struct
VerifierHandle
{
deleting
:
Arc
<
AtomicBool
>
,
sleep
:
Arc
<
(
Mutex
<
bool
>
,
Condvar
)
>
,
sleep
:
Arc
<
AtomicBool
>
,
thread
:
JoinHandle
<
()
>
,
}
impl
VerifierHandle
{
// signal to the verifier thread that it should sleep.
fn
sleep
(
&
self
)
{
*
self
.sleep
.
0
.lock
()
=
true
;
self
.sleep
.
store
(
true
,
AtomicOrdering
::
SeqCst
)
;
}
// signal to the verifier thread that it should wake up.
fn
wake_up
(
&
self
)
{
*
self
.sleep
.
0
.lock
()
=
false
;
self
.
sleep
.1
.notify_all
();
self
.sleep
.
store
(
false
,
AtomicOrdering
::
SeqCst
)
;
self
.
thread
.thread
()
.unpark
();
}
// signal to the verifier thread that it should conclude its
...
...
@@ -91,7 +91,7 @@ impl VerifierHandle {
// join the verifier thread.
fn
join
(
self
)
{
self
.thread
.join
()
.
unwrap
(
);
self
.thread
.join
()
.
expect
(
"Verifier thread panicked"
);
}
}
...
...
@@ -241,9 +241,9 @@ impl<K: Kind> VerificationQueue<K> {
// enable only the first few verifiers.
let
sleep
=
if
i
<
default_amount
{
Arc
::
new
(
(
Mutex
::
new
(
false
)
,
Condvar
::
new
())
)
Arc
::
new
(
AtomicBool
::
new
(
false
))
}
else
{
Arc
::
new
(
(
Mutex
::
new
(
true
),
Condvar
::
new
()
))
Arc
::
new
(
AtomicBool
::
new
(
true
))
};
verifiers
.push
(
VerifierHandle
{
...
...
@@ -283,14 +283,13 @@ impl<K: Kind> VerificationQueue<K> {
ready
:
Arc
<
QueueSignal
>
,
deleting
:
Arc
<
AtomicBool
>
,
empty
:
Arc
<
SCondvar
>
,
sleep
:
Arc
<
(
Mutex
<
bool
>
,
Condvar
)
>
,
sleep
:
Arc
<
AtomicBool
>
,
)
{
while
!
deleting
.load
(
AtomicOrdering
::
Acquire
)
{
{
let
mut
should_sleep
=
sleep
.0
.lock
();
while
*
should_sleep
{
while
sleep
.load
(
AtomicOrdering
::
SeqCst
)
{
trace!
(
target
:
"verification"
,
"Verifier sleeping"
);
sleep
.1
.wait
(
&
mut
should_sleep
);
::
std
::
thread
::
park
(
);
trace!
(
target
:
"verification"
,
"Verifier waking up"
);
if
deleting
.load
(
AtomicOrdering
::
Acquire
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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