Skip to content

Commit 3a6200c

Browse files
committed
fix: strange compilation error leaked by compiler
1 parent 73ddde3 commit 3a6200c

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Version 0.10.1
2+
3+
## Changed
4+
Fix a strange compilation error that was leaked by the compiler. ([#30](https://github.com/BinChengZhao/delay-timer/issues/30)), thanks `elderbig` !
5+
16
# Version 0.10.0
27

38
## Changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "delay_timer"
3-
version = "0.10.0"
3+
version = "0.10.1"
44
authors = ["binchengZhao <binchengZhao@outlook.com>"]
55
edition = "2018"
66
repository = "https://github.com/BinChengZhao/delay-timer"

examples/demo_async_std_and_tracing.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async fn main() -> Result<()> {
2323
}
2424

2525
info!("==== All job is be init! ====");
26-
for _ in 0..120 {
26+
for _ in 0..300 {
2727
Timer::after(Duration::from_secs(60)).await;
2828
}
2929
Ok(delay_timer.stop_delay_timer()?)
@@ -32,11 +32,12 @@ async fn main() -> Result<()> {
3232
fn build_task_async_execute_process(task_id: u64) -> Result<Task, TaskError> {
3333
let mut task_builder = TaskBuilder::default();
3434

35+
// Remind the user to set a timeout that must be reasonable.
3536
let body = unblock_process_task_fn("echo hello".into());
3637
task_builder
3738
.set_frequency_by_candy(CandyFrequency::Repeated(CandyCron::Secondly))
3839
.set_task_id(task_id)
39-
.set_maximum_running_time(10)
40+
.set_maximum_running_time(2)
4041
.set_maximum_parallel_runnable_num(1)
4142
.spawn(body)
4243
}

src/timer/runtime_trace/sweeper.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,13 @@ impl RecyclingBins {
139139
.unwrap_or_else(|e| error!(" `send_timer_event` : {}", e));
140140
}
141141

142+
// FIXME: https://github.com/BinChengZhao/delay-timer/issues/28
143+
// Due to the large number of tasks upstream, timeout units can pile up exceptionally high.
144+
// A large amount of memory may be occupied here.
142145
pub(crate) async fn add_recycle_unit(self: Arc<Self>) {
143146
'loopLayer: loop {
147+
// TODO: Internal (shrink -> cycle-bins) or change the data structure.
148+
144149
for _ in 0..200 {
145150
match self.recycle_unit_sources.recv().await {
146151
Ok(recycle_unit) => {

src/timer/timer_core.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ impl Timer {
217217

218218
trace!("timestamp: {}, task_ids: {:?}", timestamp, task_ids);
219219

220+
// Centralize task processing to avoid duplicate lock requests and releases.
221+
// FIXME: https://github.com/BinChengZhao/delay-timer/issues/29
220222
for task_id in task_ids {
221223
let task_option: Option<Task>;
222224

src/utils/parse.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// Collection of functions related to shell commands and processes.
55
pub mod shell_command {
66
use crate::prelude::*;
7-
use anyhow::*;
7+
use anyhow::Error as AnyhowError;
88

99
use async_trait::async_trait;
1010

@@ -329,7 +329,7 @@ pub mod shell_command {
329329
}
330330

331331
#[cfg(SPLIT_INCLUSIVE_COMPATIBLE)]
332-
fn _has_redirect_file(command: &str) -> Option<Result<File>> {
332+
fn _has_redirect_file(command: &str) -> Option<Result<File, AnyhowError>> {
333333
let angle_bracket = if command.contains(">>") {
334334
">>"
335335
} else if command.contains('>') {
@@ -346,14 +346,14 @@ pub mod shell_command {
346346
}
347347

348348
//After confirming that there is a redirect file, parse the command before the command '>'.
349-
fn _remove_angle_bracket_command(command: &str) -> Result<&str> {
349+
fn _remove_angle_bracket_command(command: &str) -> Result<&str, AnyhowError> {
350350
let mut sub_command_inner = command.trim().split('>');
351351
sub_command_inner
352352
.next()
353353
.ok_or_else(|| anyhow!("can't parse ...."))
354354
}
355355

356-
fn create_stdio_file(angle_bracket: &str, filename: &str) -> Result<File> {
356+
fn create_stdio_file(angle_bracket: &str, filename: &str) -> Result<File, AnyhowError> {
357357
let mut file_tmp = OpenOptions::new();
358358
file_tmp.write(true).create(true);
359359

0 commit comments

Comments
 (0)