Struct delay_timer::timer::task::TaskBuilder
source · pub struct TaskBuilder<'a> { /* private fields */ }
Expand description
Cycle plan task builder.
Implementations§
source§impl<'a> TaskBuilder<'a>
impl<'a> TaskBuilder<'a>
sourcepub fn set_frequency(&mut self, frequency: Frequency<'a>) -> &mut Self
👎Deprecated
pub fn set_frequency(&mut self, frequency: Frequency<'a>) -> &mut Self
Set task Frequency.
This api will be deprecated in the future, please use set_frequency_once_*
| set_frequency_count_down_*
| set_frequency_repeated_*
etc.
sourcepub fn set_frequency_by_candy<T: Into<CandyCronStr>>(
&mut self,
frequency: CandyFrequency<T>
) -> &mut Self
👎Deprecated
pub fn set_frequency_by_candy<T: Into<CandyCronStr>>( &mut self, frequency: CandyFrequency<T> ) -> &mut Self
Set task Frequency by customized CandyCronStr.
In order to build a high-performance,
highly reusable TaskBuilder
that maintains the Copy feature .
when supporting building from CandyCronStr , here actively leaks memory for create a str-slice (because str-slice support Copy, String does not)
We need to call free
manually before TaskBuilder
drop or before we leave the scope.
Explain:
Explicitly implementing both Drop
and Copy
trait on a type is currently
disallowed.
This feature can make some sense in theory, but the current
implementation is incorrect and can lead to memory unsafety (see
(issue #20126), so it has been disabled for now.
This api will be deprecated in the future, please use set_frequency_*_by_candy
etc.
sourcepub fn set_task_id(&mut self, task_id: u64) -> &mut Self
pub fn set_task_id(&mut self, task_id: u64) -> &mut Self
Set task-id.
sourcepub fn set_maximum_running_time(
&mut self,
maximum_running_time: u64
) -> &mut Self
pub fn set_maximum_running_time( &mut self, maximum_running_time: u64 ) -> &mut Self
Set maximum execution time (optional).
sourcepub fn set_maximum_parallel_runnable_num(
&mut self,
maximum_parallel_runnable_num: u64
) -> &mut Self
pub fn set_maximum_parallel_runnable_num( &mut self, maximum_parallel_runnable_num: u64 ) -> &mut Self
Set a task with the maximum number of parallel runs (optional).
sourcepub fn set_schedule_iterator_time_zone(
&mut self,
schedule_iterator_time_zone: ScheduleIteratorTimeZone
) -> &mut Self
pub fn set_schedule_iterator_time_zone( &mut self, schedule_iterator_time_zone: ScheduleIteratorTimeZone ) -> &mut Self
Set time zone for cron-expression iteration time.
sourcepub fn spawn_async_routine<F: Fn() -> U + 'static + Send, U: Future + 'static + Send>(
self,
routine: F
) -> Result<Task, TaskError>
pub fn spawn_async_routine<F: Fn() -> U + 'static + Send, U: Future + 'static + Send>( self, routine: F ) -> Result<Task, TaskError>
Spawn a task with async-routine.
sourcepub fn spawn_routine<F: Fn() + 'static + Send + Clone>(
self,
routine: F
) -> Result<Task, TaskError>
pub fn spawn_routine<F: Fn() + 'static + Send + Clone>( self, routine: F ) -> Result<Task, TaskError>
Spawn a task with sync-routine.
sourcepub fn free(&mut self)
pub fn free(&mut self)
If we call set_frequency_by_candy explicitly and generate TaskBuilder,
We need to call free
manually before TaskBuilder
drop or before we leave the scope.
Explain:
Explicitly implementing both Drop
and Copy
trait on a type is currently
disallowed. This feature can make some sense in theory, but the current
implementation is incorrect and can lead to memory unsafety (see
(issue #20126), so it has been disabled for now.
So I can’t go through Drop and handle these automatically.
source§impl<'a> TaskBuilder<'a>
impl<'a> TaskBuilder<'a>
sourcepub fn set_frequency_once_by_cron_str(&mut self, cron_str: &'a str) -> &mut Self
pub fn set_frequency_once_by_cron_str(&mut self, cron_str: &'a str) -> &mut Self
Task execution frequency: execute only once, set by cron expression.
sourcepub fn set_frequency_repeated_by_cron_str(
&mut self,
cron_str: &'a str
) -> &mut Self
pub fn set_frequency_repeated_by_cron_str( &mut self, cron_str: &'a str ) -> &mut Self
Task execution frequency: countdown execution, set by cron expression.
sourcepub fn set_frequency_count_down_by_cron_str(
&mut self,
cron_str: &'a str,
count_down: u64
) -> &mut Self
pub fn set_frequency_count_down_by_cron_str( &mut self, cron_str: &'a str, count_down: u64 ) -> &mut Self
Task execution frequency: execute repeatedly, set by cron expression.
sourcepub fn set_frequency_once_by_seconds(&mut self, seconds: u64) -> &mut Self
pub fn set_frequency_once_by_seconds(&mut self, seconds: u64) -> &mut Self
Task execution frequency: execute only once, set by seconds num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_repeated_by_seconds(&mut self, seconds: u64) -> &mut Self
pub fn set_frequency_repeated_by_seconds(&mut self, seconds: u64) -> &mut Self
Task execution frequency: countdown execution, set by seconds num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_count_down_by_seconds(
&mut self,
seconds: u64,
count_down: u64
) -> &mut Self
pub fn set_frequency_count_down_by_seconds( &mut self, seconds: u64, count_down: u64 ) -> &mut Self
Task execution frequency: execute repeatedly, set by seconds num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_once_by_minutes(&mut self, minutes: u64) -> &mut Self
pub fn set_frequency_once_by_minutes(&mut self, minutes: u64) -> &mut Self
Task execution frequency: execute only once, set by minutes num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_repeated_by_minutes(&mut self, minutes: u64) -> &mut Self
pub fn set_frequency_repeated_by_minutes(&mut self, minutes: u64) -> &mut Self
Task execution frequency: countdown execution, set by minutes num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_count_down_by_minutes(
&mut self,
minutes: u64,
count_down: u64
) -> &mut Self
pub fn set_frequency_count_down_by_minutes( &mut self, minutes: u64, count_down: u64 ) -> &mut Self
Task execution frequency: execute repeatedly, set by minutes num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_once_by_hours(&mut self, hours: u64) -> &mut Self
pub fn set_frequency_once_by_hours(&mut self, hours: u64) -> &mut Self
Task execution frequency: execute only once, set by hours num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_repeated_by_hours(&mut self, hours: u64) -> &mut Self
pub fn set_frequency_repeated_by_hours(&mut self, hours: u64) -> &mut Self
Task execution frequency: execute repeatedly, set by hours num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_count_down_by_hours(
&mut self,
hours: u64,
count_down: u64
) -> &mut Self
pub fn set_frequency_count_down_by_hours( &mut self, hours: u64, count_down: u64 ) -> &mut Self
Task execution frequency: countdown execution, set by hours num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_once_by_days(&mut self, days: u64) -> &mut Self
pub fn set_frequency_once_by_days(&mut self, days: u64) -> &mut Self
Task execution frequency: execute only once, set by days num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_repeated_by_days(&mut self, days: u64) -> &mut Self
pub fn set_frequency_repeated_by_days(&mut self, days: u64) -> &mut Self
Task execution frequency: execute repeatedly, set by days num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_count_down_by_days(
&mut self,
days: u64,
count_down: u64
) -> &mut Self
pub fn set_frequency_count_down_by_days( &mut self, days: u64, count_down: u64 ) -> &mut Self
Task execution frequency: countdown execution, set by days num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
sourcepub fn set_frequency_once_by_timestamp_seconds(
&mut self,
timestamp_seconds: u64
) -> &mut Self
pub fn set_frequency_once_by_timestamp_seconds( &mut self, timestamp_seconds: u64 ) -> &mut Self
Task execution frequency: execute only once, set by timestamp-seconds num.
Make sure time is greater than 1 seconds, otherwise undefined behavior will be triggered.
Trait Implementations§
source§impl<'a> Clone for TaskBuilder<'a>
impl<'a> Clone for TaskBuilder<'a>
source§fn clone(&self) -> TaskBuilder<'a>
fn clone(&self) -> TaskBuilder<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more