pub async fn spawn<F, T>(&self, func: F) -> Result<T>
    where
        F: FnOnce(LeasedItem<Searcher>, &tantivy::Executor) -> T + Send + 'static,
        T: Sync + Send + 'static,
    {
        let _permit = self.limiter.acquire().await?;
        let executor = self.reader_executors.get().await?;
        let searcher = self.reader.searcher();
        let (tx, rx) = oneshot::channel();
        self.thread_pool.spawn(move || {
            let result = func(searcher, executor.borrow());
            let _ = tx.send(result);
        });

        Ok(rx.await?)
    }
/// Spawns a new function into the pool and returns
/// the results once complete.
Spawns a new function into the pool and returns
the results once complete.
Spawns a new function into the pool and returns the results once complete .
pub async fn spawn<F, T>(&self, func: F) -> Result<T>
    where
        F: FnOnce(LeasedItem<Searcher>, &tantivy::Executor) -> T + Send + 'static,
        T: Sync + Send + 'static,
    {
        let _permit = self.limiter.acquire().await?;
        let executor = self.reader_executors.get().await?;
        let searcher = self.reader.searcher();
        let (tx, rx) = oneshot::channel();
        self.thread_pool.spawn(move || {
            let result = func(searcher, executor.borrow());
            let _ = tx.send(result);
        });
        Ok(rx.await?)
    }
pub async fn spawn < F , T > ( & self , func : F ) -> Result < T > where F : FnOnce ( LeasedItem < Searcher > , & tantivy :: Executor ) -> T + Send + ' static , T : Sync + Send + ' static , { let _permit = self . limiter . acquire ( ) . await ? ; let executor = self . reader_executors . get ( ) . await ? ; let searcher = self . reader . searcher ( ) ; let ( tx , rx ) = oneshot :: channel ( ) ; self . thread_pool . spawn ( move | | { let result = func ( searcher , executor . borrow ( ) ) ; let _ = tx . send ( result ) ; } ) ; Ok ( rx . await ? ) }
Spawns a new function into the pool and returns
the results once complete.
Spawns a new function into the pool and returns the results once complete .
&self
func
F
&self
func
F