Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Hacksaar
rinx
Commits
b2b310fe
Commit
b2b310fe
authored
Feb 18, 2016
by
Ralf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cargo fmt
parent
e76cfc7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
9 deletions
+7
-9
src/input/mod.rs
src/input/mod.rs
+0
-1
src/util/wakeable.rs
src/util/wakeable.rs
+7
-8
No files found.
src/input/mod.rs
View file @
b2b310fe
...
...
@@ -10,4 +10,3 @@ pub enum Event {
Buzz
,
UserCommand
,
}
src/util/wakeable.rs
View file @
b2b310fe
...
...
@@ -18,25 +18,24 @@ struct ThreadState {
}
pub
trait
SpawnWakeable
<
'a
>
{
fn
spawn_wakeable
<
F
>
(
&
self
,
f
:
F
)
where
F
:
FnOnce
(
WakeableThread
)
+
Send
+
'a
;
fn
spawn_wakeable
<
F
>
(
&
self
,
f
:
F
)
where
F
:
FnOnce
(
WakeableThread
)
+
Send
+
'a
;
}
impl
<
'a
>
SpawnWakeable
<
'a
>
for
Scope
<
'a
>
{
fn
spawn_wakeable
<
F
>
(
&
self
,
f
:
F
)
where
F
:
FnOnce
(
WakeableThread
)
+
Send
+
'a
fn
spawn_wakeable
<
F
>
(
&
self
,
f
:
F
)
where
F
:
FnOnce
(
WakeableThread
)
+
Send
+
'a
{
let
state
=
Arc
::
new
(
ThreadState
{
mutex
:
Mutex
::
new
(
ShouldThreadRun
::
Yes
),
cond
:
Condvar
::
new
(),
});
let
thread
=
WakeableThread
{
state
:
state
.clone
()
};
self
.spawn
(
move
||
f
(
thread
)
);
self
.spawn
(
move
||
f
(
thread
));
// Now defer the action that we want to wake up this thread.
// This will be executed *before* the join deferred by spawn.
self
.defer
(
move
||
{
// We panic if the lock is poisened, which only happens if someone paniced
let
mut
should_run
=
state
.mutex
.lock
()
.unwrap
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment