Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PERE Alexandre
orchestra
Commits
a9b77ff2
Commit
a9b77ff2
authored
Nov 08, 2019
by
Alexandre Pere
Browse files
Adds Timer implementation
parent
9c89cd51
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
liborchestra/Cargo.toml
View file @
a9b77ff2
...
...
@@ -36,6 +36,8 @@ tracing-subscriber = "0.1.5"
tracing-attributes
=
"0.1.5"
tracing-futures
=
{
version
=
"0.1.0"
,
features
=
["futures-preview"]
}
derivative
=
"1.0.3"
arrayvec
=
"0.5.1"
lazy_static
=
"1.4.0"
[lib]
name
=
"liborchestra"
...
...
liborchestra/src/lib/misc.rs
View file @
a9b77ff2
...
...
@@ -12,6 +12,14 @@ use regex;
use
super
::
CMPCONF_RPATH
;
use
tracing
::{
self
,
warn
,
debug
};
use
super
::
commons
::
OutputBuf
;
use
super
::
timer
::
TimerHandle
;
//------------------------------------------------------------------------------------------- STATIC
lazy_static!
{
pub
static
ref
TIMER
:
TimerHandle
=
TimerHandle
::
spawn
()
.expect
(
"Failed to spawn timer."
);
}
//------------------------------------------------------------------------------------------- ERRORS
...
...
@@ -45,17 +53,8 @@ impl fmt::Display for Error {
macro_rules!
async_sleep
{
(
$dur
:
expr
)
=>
{
{
let
(
tx
,
rx
)
=
oneshot
::
channel
();
thread
::
spawn
(
move
||
{
thread
::
sleep
(
$dur
);
tx
.send
(())
.unwrap
();
});
use
tracing_futures
::
Instrument
;
use
tracing
::
trace_span
;
rx
.instrument
(
trace_span!
(
"async_sleep!"
))
.await
.unwrap
();
use
crate
::
misc
::
TIMER
;
(
*
TIMER
)
.async_sleep
(
$dur
)
.await
.unwrap
();
}
};
}
...
...
@@ -72,7 +71,7 @@ macro_rules! await_wouldblock_io {
loop
{
match
$expr
{
Err
(
ref
e
)
if
e
.kind
()
==
std
::
io
::
ErrorKind
::
WouldBlock
=>
{
async_sleep!
(
std
::
time
::
Duration
::
from_
nano
s
(
1
))
async_sleep!
(
std
::
time
::
Duration
::
from_
milli
s
(
2
))
}
res
=>
break
res
,
}
...
...
@@ -93,10 +92,10 @@ macro_rules! await_wouldblock_ssh {
loop
{
match
$expr
{
Err
(
ref
e
)
if
e
.code
()
==
-
37
=>
{
async_sleep!
(
std
::
time
::
Duration
::
from_
nano
s
(
1
))
async_sleep!
(
std
::
time
::
Duration
::
from_
milli
s
(
2
))
}
Err
(
ref
e
)
if
e
.code
()
==
-
21
=>
{
async_sleep!
(
std
::
time
::
Duration
::
from_
nano
s
(
1
))
async_sleep!
(
std
::
time
::
Duration
::
from_
milli
s
(
2
))
}
res
=>
break
res
,
}
...
...
@@ -124,7 +123,7 @@ macro_rules! await_retry_n_ssh {
}
$
(
else
if
e
.code
()
==
$code
as
i32
{
async_sleep!
(
std
::
time
::
Duration
::
from_
nano
s
(
1
));
async_sleep!
(
std
::
time
::
Duration
::
from_
milli
s
(
2
));
i
+=
1
;
}
)
*
...
...
@@ -151,7 +150,7 @@ macro_rules! await_retry_ssh {
match
$expr
{
Err
(
e
)
=>
{
$
(
if
e
.code
()
==
$code
as
i32
{
async_sleep!
(
std
::
time
::
Duration
::
from_
nano
s
(
1
));
async_sleep!
(
std
::
time
::
Duration
::
from_
milli
s
(
2
));
}
else
)
*
{
break
Err
(
e
)
...
...
@@ -184,7 +183,7 @@ macro_rules! await_retry_n {
break
Err
(
e
)
}
else
{
async_sleep!
(
std
::
time
::
Duration
::
from_
nano
s
(
1
));
async_sleep!
(
std
::
time
::
Duration
::
from_
milli
s
(
2
));
i
+=
1
;
}
}
...
...
liborchestra/src/lib/mod.rs
View file @
a9b77ff2
...
...
@@ -275,11 +275,14 @@ extern crate ssh2;
extern
crate
dirs
;
extern
crate
libc
;
extern
crate
chrono
;
extern
crate
arrayvec
;
#[macro_use]
extern
crate
serde_derive
;
#[macro_use]
extern
crate
derivative
;
#[macro_use]
extern
crate
lazy_static
;
//------------------------------------------------------------------------------------------ MODULES
...
...
@@ -291,6 +294,7 @@ pub mod repository;
pub
mod
primitives
;
pub
mod
scheduler
;
pub
mod
commons
;
pub
mod
timer
;
#[macro_use]
pub
mod
error
;
...
...
liborchestra/src/lib/timer.rs
0 → 100644
View file @
a9b77ff2
This diff is collapsed.
Click to expand it.
runaway-cli/src/misc.rs
View file @
a9b77ff2
...
...
@@ -32,7 +32,6 @@ lazy_static!{
pub
static
ref
NO_COLORS
:
bool
=
env
::
var
(
"NO_COLOR"
)
.is_ok
();
}
//-------------------------------------------------------------------------------------------- MACRO
...
...
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