Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kernel
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
Container Registry
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
redox-os
kernel
Commits
a97aa95c
Commit
a97aa95c
authored
8 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Improve wait condition performance
parent
962836aa
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
sync/wait_condition.rs
+5
-6
5 additions, 6 deletions
sync/wait_condition.rs
with
5 additions
and
6 deletions
sync/wait_condition.rs
+
5
−
6
View file @
a97aa95c
use
alloc
::
arc
::
Arc
;
use
alloc
::
arc
::
Arc
;
use
collections
::
Vec
;
use
collections
::
Vec
;
use
core
::
mem
;
use
spin
::{
Mutex
,
RwLock
};
use
spin
::{
Mutex
,
RwLock
};
use
context
::{
self
,
Context
};
use
context
::{
self
,
Context
};
...
@@ -13,17 +12,17 @@ pub struct WaitCondition {
...
@@ -13,17 +12,17 @@ pub struct WaitCondition {
impl
WaitCondition
{
impl
WaitCondition
{
pub
fn
new
()
->
WaitCondition
{
pub
fn
new
()
->
WaitCondition
{
WaitCondition
{
WaitCondition
{
contexts
:
Mutex
::
new
(
Vec
::
new
(
))
contexts
:
Mutex
::
new
(
Vec
::
with_capacity
(
16
))
}
}
}
}
pub
fn
notify
(
&
self
)
->
usize
{
pub
fn
notify
(
&
self
)
->
usize
{
let
mut
contexts
=
Vec
::
new
();
let
mut
contexts
=
self
.contexts
.lock
();
mem
::
swap
(
&
mut
*
self
.contexts
.lock
(),
&
mut
contexts
);
let
len
=
contexts
.len
(
);
for
context_lock
in
contexts
.
iter
()
{
while
let
Some
(
context_lock
)
=
contexts
.
pop
()
{
context_lock
.write
()
.unblock
();
context_lock
.write
()
.unblock
();
}
}
contexts
.
len
()
len
}
}
pub
fn
wait
(
&
self
)
{
pub
fn
wait
(
&
self
)
{
...
...
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