pub fn spawn(
            future: impl Future<Output = Result<[SigningMessage; N]>> + Send + 'static,
        ) -> Self {
            let result = Arc::new(Mutex::new(None));
            let set_result = result.clone();

            let task = phala_async_executor::spawn(async move {
                let result = future.await;
                if let Err(err) = &result {
                    log::error!("Async side task returns error: {:?}", err);
                }
                *set_result.lock().unwrap() = result.ok();
            });

            AsyncSideTask {
                result,
                _async_task: task,
            }
        }
/// Create a new `AsyncSideTask`.
///
/// The `future` is a future to do an async task (e.g. a http request) to fetch some async resoures.
///
/// # Examples
///
/// ```ignore
/// let mut task_man = SideTaskManager::default();
/// let cur_block = 100;
/// let duration = 3;
/// let task = AsyncSideTask::spawn(async {
///         let ip = surf::get("https://ifconfig.me").await.unwrap().body_string().await.unwrap()
///         [msg_ch.prepare_message(mk_msg_from_ip(ip))]
///     },
/// );
/// task_man.add_task(cur_block, duration, [mk_default_msg()], |c| task.finish(c));
/// ```
Create a new `AsyncSideTask`.
The `future` is a future to do an async task  to fetch some async resoures.
Create a new ` AsyncSideTask ` . The ` future ` is a future to do an async task to fetch some async resoures .
pub fn spawn(
            future: impl Future<Output = Result<[SigningMessage; N]>> + Send + 'static,
        ) -> Self {
            let result = Arc::new(Mutex::new(None));
            let set_result = result.clone();
            let task = phala_async_executor::spawn(async move {
                let result = future.await;
                if let Err(err) = &result {
                    log::error!("Async side task returns error: {:?}", err);
                }
                *set_result.lock().unwrap() = result.ok();
            });
            AsyncSideTask {
                result,
                _async_task: task,
            }
        }
pub fn spawn ( future : impl Future < Output = Result < [ SigningMessage ; N ] > > + Send + ' static , ) -> Self { let result = Arc :: new ( Mutex :: new ( None ) ) ; let set_result = result . clone ( ) ; let task = phala_async_executor :: spawn ( async move { let result = future . await ; if let Err ( err ) = & result { log :: error ! ( " " err ) ; } * set_result . lock ( ) . unwrap ( ) = result . ok ( ) ; } ) ; AsyncSideTask { result , _async_task : task , } }
Create a new `AsyncSideTask`.
Create a new ` AsyncSideTask ` .
future
impl Future<Output = Result<[SigningMessage; N]>> + Send + 'static
future
impl Future<Output = Result<[SigningMessage; N]>> + Send + 'static
examples
None