Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
G
grapeTimerR
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
jackliu
grapeTimerR
Commits
c2e27eb6
Commit
c2e27eb6
authored
4 years ago
by
jackliu
Browse files
Options
Downloads
Patches
Plain Diff
修正单词拼写错误
parent
17a98e22
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+5
-5
5 additions, 5 deletions
README.md
src/lib.rs
+11
-11
11 additions, 11 deletions
src/lib.rs
src/thread.rs
+1
-1
1 addition, 1 deletion
src/thread.rs
with
17 additions
and
17 deletions
README.md
+
5
−
5
View file @
c2e27eb6
...
...
@@ -90,13 +90,13 @@ let next_dayTimeUtc = parsers::parser_timestampUtc("Day 05::00:00").unwrap();
**add ticker**
```
rust
fn
execut
e
r_task
(
id
:
u64
)
{
fn
execut
o
r_task
(
id
:
u64
)
{
println!
(
"on function mode:{}"
,
chrono
::
Local
::
now
()
.to_rfc2822
());
}
// 使用函数方式执行代码 Use function to execute code
timer
::
sp
w
an_ticker
(
time
::
Duration
::
from_millis
(
5000
),
2
,
execut
e
r_task
);
timer
::
spa
w
n_ticker
(
time
::
Duration
::
from_millis
(
5000
),
2
,
execut
o
r_task
);
// 使用闭包模式 Use closure function
timer
::
sp
w
an_ticker
(
time
::
Duration
::
from_millis
(
5000
),
2
,|
x
|
{
timer
::
spa
w
n_ticker
(
time
::
Duration
::
from_millis
(
5000
),
2
,|
x
|
{
println!
(
"on ticker:{}"
,
chrono
::
Local
::
now
()
.to_rfc2822
());
});
```
...
...
@@ -143,14 +143,14 @@ impl TaskAction for ExempleAction {
// 使用trait任务,可以简化部分实际逻辑
// Using trait tasks can simplify part of the actual logic
timer
::
sp
w
an_trait
(
Arc
::
new
(
ExempleAction
{}));
timer
::
spa
w
n_trait
(
Arc
::
new
(
ExempleAction
{}));
```
**add date**
```
rust
timer
::
sp
w
an_date
(
"day 19:21:50"
,
1
,|
id
|
{
timer
::
spa
w
n_date
(
"day 19:21:50"
,
1
,|
id
|
{
println!
(
"on date:{}"
,
chrono
::
Local
::
now
()
.to_rfc2822
());
});
```
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
11
−
11
View file @
c2e27eb6
...
...
@@ -156,24 +156,24 @@ pub mod timer {
/// use grapeTimerR::timer;
/// use std::time;
///
/// fn execut
e
r_task(id:u64) {
/// fn execut
o
r_task(id:u64) {
/// println!("on function mode:{}",chrono::Local::now().to_rfc2822());
/// }
/// // 使用函数方式执行代码 Use function to execute code
/// timer::sp
w
an_ticker(time::Duration::from_millis(5000),2,execut
e
r_task);
/// timer::spa
w
n_ticker(time::Duration::from_millis(5000),2,execut
o
r_task);
/// // 使用闭包模式 Use closure function
/// timer::sp
w
an_ticker(time::Duration::from_millis(5000),2,|x| {
/// timer::spa
w
n_ticker(time::Duration::from_millis(5000),2,|x| {
/// println!("on ticker:{}",chrono::Local::now().to_rfc2822());
/// });
/// ```
pub
fn
sp
w
an_t
icker
(
tick
:
time
::
Duration
,
loopCount
:
i32
,
f
:
impl
Fn
(
u64
)
+
Send
+
Sync
+
'static
)
->
TResult
<
u64
>
{
pub
fn
spa
w
n_t
rait
(
tick
:
time
::
Duration
,
loopCount
:
i32
,
f
:
impl
Fn
(
u64
)
+
Send
+
Sync
+
'static
)
->
TResult
<
u64
>
{
let
task_action
=
ClosuresAction
::
new
(
""
,
next_uuid
(),
loopCount
,
tick
,
f
);
let
r
=
Inter
.thread_pool
.lock
();
match
r
{
Err
(
e
)
=>
{
Err
(
TError
::
new
(
TErrorKind
::
Other
(
e
.to_string
())))
},
Ok
(
mut
v
)
=>
{
let
task_id
=
task_action
.id
();
v
.sp
w
an
(
Arc
::
new
(
task_action
));
v
.spa
w
n
(
Arc
::
new
(
task_action
));
Ok
(
task_id
)
}
}
...
...
@@ -226,15 +226,15 @@ pub mod timer {
/// }
/// // 使用trait任务,可以简化部分实际逻辑
/// // Using trait tasks can simplify part of the actual logic
/// timer::sp
w
an_trait(Arc::new(ExempleAction{}));
/// timer::spa
w
n_trait(Arc::new(ExempleAction{}));
/// ```
pub
fn
sp
w
an_trait
(
ft
:
Arc
<
dyn
TaskAction
>
)
->
TResult
<
u64
>
{
pub
fn
spa
w
n_trait
(
ft
:
Arc
<
dyn
TaskAction
>
)
->
TResult
<
u64
>
{
let
r
=
Inter
.thread_pool
.lock
();
match
r
{
Err
(
e
)
=>
{
Err
(
TError
::
new
(
TErrorKind
::
Other
(
e
.to_string
())))
},
Ok
(
mut
v
)
=>
{
let
taskId
=
ft
.id
();
v
.sp
w
an
(
ft
);
v
.spa
w
n
(
ft
);
Ok
(
taskId
)
}
}
...
...
@@ -246,18 +246,18 @@ pub mod timer {
///
/// ```
/// use grapeTimerR::timer;
/// timer::sp
w
an_date("day 19:30:00",1,|id| {
/// timer::spa
w
n_date("day 19:30:00",1,|id| {
/// println!("on date:{}",chrono::Local::now().to_rfc2822());
/// });
/// ```
pub
fn
sp
w
an_date
(
dateformate
:
&
str
,
loopCount
:
i32
,
f
:
impl
Fn
(
u64
)
+
Send
+
Sync
+
'static
)
->
TResult
<
u64
>
{
pub
fn
spa
w
n_date
(
dateformate
:
&
str
,
loopCount
:
i32
,
f
:
impl
Fn
(
u64
)
+
Send
+
Sync
+
'static
)
->
TResult
<
u64
>
{
let
task_action
=
ClosuresAction
::
new
(
dateformate
,
next_uuid
(),
loopCount
,
time
::
Duration
::
from_secs
(
0
),
f
);
let
r
=
Inter
.thread_pool
.lock
();
match
r
{
Err
(
e
)
=>
{
Err
(
TError
::
new
(
TErrorKind
::
Other
(
e
.to_string
())))
},
Ok
(
mut
v
)
=>
{
let
task_id
=
task_action
.id
();
v
.sp
w
an
(
Arc
::
new
(
task_action
));
v
.spa
w
n
(
Arc
::
new
(
task_action
));
Ok
(
task_id
)
}
}
...
...
This diff is collapsed.
Click to expand it.
src/thread.rs
+
1
−
1
View file @
c2e27eb6
...
...
@@ -54,7 +54,7 @@ pub mod threads {
}
}
pub
fn
sp
w
an
(
&
self
,
t
:
Arc
<
dyn
TaskAction
>
)
{
pub
fn
spa
w
n
(
&
self
,
t
:
Arc
<
dyn
TaskAction
>
)
{
let
task
=
t
.clone
();
let
rx_spwan
=
self
.stop_rx
.clone
();
let
debug
=
self
.debug
;
...
...
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