Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ufoscout committed Mar 14, 2024
1 parent ce3c6de commit ce067e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 42 deletions.
22 changes: 20 additions & 2 deletions ic-task-scheduler/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,16 @@ impl<T: 'static + Task, P: 'static + IterableUnboundedMapStructure<u32, InnerSch
let time_secs = time_secs();
let mut lock = self.pending_tasks.lock();
let key = lock.last_key().map(|val| val + 1).unwrap_or_default();
lock.insert(&key, &InnerScheduledTask::waiting(key, task, time_secs));
lock.insert(
&key,
&InnerScheduledTask::with_status(
key,
task,
TaskStatus::Waiting {
timestamp_secs: time_secs,
},
),
);
key
}

Expand All @@ -254,7 +263,16 @@ impl<T: 'static + Task, P: 'static + IterableUnboundedMapStructure<u32, InnerSch

let mut keys = Vec::with_capacity(tasks.len());
for task in tasks {
lock.insert(&key, &InnerScheduledTask::waiting(key, task, time_secs));
lock.insert(
&key,
&InnerScheduledTask::with_status(
key,
task,
TaskStatus::Waiting {
timestamp_secs: time_secs,
},
),
);
keys.push(key);
key += 1;
}
Expand Down
40 changes: 0 additions & 40 deletions ic-task-scheduler/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,46 +70,6 @@ impl<T: Task> InnerScheduledTask<T> {
}
}

/// Creates a new InnerScheduledTask with Waiting status
pub fn waiting(id: u32, task: ScheduledTask<T>, timestamp_secs: u64) -> Self {
Self {
id,
task: task.task,
options: task.options,
status: TaskStatus::Waiting { timestamp_secs },
}
}

/// Creates a new InnerScheduledTask with Complete status
pub fn completed(id: u32, task: ScheduledTask<T>, timestamp_secs: u64) -> Self {
Self {
id,
task: task.task,
options: task.options,
status: TaskStatus::Completed { timestamp_secs },
}
}

/// Creates a new InnerScheduledTask with TimeoutOrPanic status
pub fn timeout_or_panic(id: u32, task: ScheduledTask<T>, timestamp_secs: u64) -> Self {
Self {
id,
task: task.task,
options: task.options,
status: TaskStatus::TimeoutOrPanic { timestamp_secs },
}
}

/// Creates a new InnerScheduledTask with Running status
pub fn running(id: u32, task: ScheduledTask<T>, timestamp_secs: u64) -> Self {
Self {
id,
task: task.task,
options: task.options,
status: TaskStatus::Running { timestamp_secs },
}
}

/// Returs the status of the task
pub fn status(&self) -> &TaskStatus {
&self.status
Expand Down

0 comments on commit ce067e2

Please sign in to comment.