pub fn add_async_task<
            F: Future<Output = Result<[SigningMessage; N]>> + Send + 'static,
            const N: usize,
        >(
            &mut self,
            current_block: BlockNumber,
            duration: BlockNumber,
            default_messages: [SigningMessage; N],
            future: F,
        ) {
            if !crate::benchmark::is_ready() {
                self.add_task(current_block, duration, default_messages, |_| None);
                return;
            }
            let task = AsyncSideTask::spawn(future);
            self.add_task(current_block, duration, default_messages, |context| {
                task.finish(context)
            });
        }
/// Create and start a new `AsyncSideTask`.
///
/// The task will finish at `block_number` + `duration` block.
/// The `future` is a future to do an async task (e.g. a http request) to fetch some async resoures
/// and returns a certain number of mq messages.
///
/// * `current_block` - The current block_number.
/// * `duration` - Number of blocks that this task persists. The task will be end at `current_block` + `duration`.
/// * `default_messages` - The alternative messages used to push out if the async block returns an error or get timed out.
/// * `future` - The main async task body.
///
/// # Examples
///
/// ```ignore
/// let mut task_man = SideTaskManager::default();
/// let mq = todo!();
/// let cur_block = 100;
/// let duration = 3;
/// task_man.add_async_task(
///     cur_block,
///     duration,
///     [mq.prepare_message("Timed out".to_string())],
///     async {
///         let ip = surf::get("https://ifconfig.me").await.unwrap().body_string().await.unwrap()
///         [mq.prepare_message(mk_msg_from_ip(ip))]
///     },
/// );
/// ```
/// # Note
/// DO NOT send mq messages directly inside the async block (future polling). Should return messages instead.
///
Create and start a new `AsyncSideTask`.
The task will finish at `block_number` + `duration` block.
The `future` is a future to do an async task  to fetch some async resoures
and returns a certain number of mq messages.


Create and start a new ` AsyncSideTask ` . The task will finish at ` block_number ` + ` duration ` block . The ` future ` is a future to do an async task to fetch some async resoures and returns a certain number of mq messages .
pub fn add_async_task<
            F: Future<Output = Result<[SigningMessage; N]>> + Send + 'static,
            const N: usize,
        >(
            &mut self,
            current_block: BlockNumber,
            duration: BlockNumber,
            default_messages: [SigningMessage; N],
            future: F,
        ) {
            if !crate::benchmark::is_ready() {
                self.add_task(current_block, duration, default_messages, |_| None);
                return;
            }
            let task = AsyncSideTask::spawn(future);
            self.add_task(current_block, duration, default_messages, |context| {
                task.finish(context)
            });
        }
pub fn add_async_task < F : Future < Output = Result < [ SigningMessage ; N ] > > + Send + ' static , const N : usize , > ( & mut self , current_block : BlockNumber , duration : BlockNumber , default_messages : [ SigningMessage ; N ] , future : F , ) { if ! crate :: benchmark :: is_ready ( ) { self . add_task ( current_block , duration , default_messages , | _ | None ) ; return ; } let task = AsyncSideTask :: spawn ( future ) ; self . add_task ( current_block , duration , default_messages , | context | { task . finish ( context ) } ) ; }
Create and start a new `AsyncSideTask`.
Create and start a new ` AsyncSideTask ` .
&mut self
current_block
BlockNumber
duration
BlockNumber
default_messages
[SigningMessage; N]
future
F
&mut self
current_block
BlockNumber
duration
BlockNumber
default_messages
[SigningMessage; N]
future
F
examples
None
note
DO NOT send mq messages directly inside the async block (future polling). Should return messages instead.
DO NOT send mq messages directly inside the async block ( future polling ) . Should return messages instead .