pub async fn execute<F, R>(&self, f: F) -> Result<R, ThreadPoolDisconnected>
    where
        F: 'static + Send + FnOnce(&Shared) -> R,
        R: 'static + Send + Sync,
    {
        let (s, r) = async_oneshot::oneshot();
        self.sender
            .send_async(MsgForWorker::NewJob(Box::new(move |shared| {
                let _ = s.send(f(shared));
            })))
            .await
            .map_err(|_| ThreadPoolDisconnected)?;

        r.await.map_err(|_| ThreadPoolDisconnected)
    }
/// Execute the given closure and return a Future that output closure return type
Execute the given closure and return a Future that output closure return type
Execute the given closure and return a Future that output closure return type
pub async fn execute<F, R>(&self, f: F) -> Result<R, ThreadPoolDisconnected>
    where
        F: 'static + Send + FnOnce(&Shared) -> R,
        R: 'static + Send + Sync,
    {
        let (s, r) = async_oneshot::oneshot();
        self.sender
            .send_async(MsgForWorker::NewJob(Box::new(move |shared| {
                let _ = s.send(f(shared));
            })))
            .await
            .map_err(|_| ThreadPoolDisconnected)?;
        r.await.map_err(|_| ThreadPoolDisconnected)
    }
pub async fn execute < F , R > ( & self , f : F ) -> Result < R , ThreadPoolDisconnected > where F : ' static + Send + FnOnce ( & Shared ) -> R , R : ' static + Send + Sync , { let ( s , r ) = async_oneshot :: oneshot ( ) ; self . sender . send_async ( MsgForWorker :: NewJob ( Box :: new ( move | shared | { let _ = s . send ( f ( shared ) ) ; } ) ) ) . await . map_err ( | _ | ThreadPoolDisconnected ) ? ; r . await . map_err ( | _ | ThreadPoolDisconnected ) }
Execute the given closure and return a Future that output closure return type
Execute the given closure and return a Future that output closure return type
&self
f
F
&self
f
F