mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-25 08:34:47 +01:00
fix: pass runtime for callback spawning
This commit is contained in:
parent
85bd3c4535
commit
853d754d8b
1 changed files with 2 additions and 2 deletions
|
@ -41,11 +41,11 @@ pub trait Controller<T> : Sized + Send + Sync {
|
|||
async fn send(&self, x: Self::Input) -> Result<(), Error>;
|
||||
async fn recv(&self) -> Result<T, Error>;
|
||||
|
||||
fn callback<F>(self: Arc<Self>, mut cb: F)
|
||||
fn callback<F>(self: Arc<Self>, rt: &tokio::runtime::Runtime, mut cb: F)
|
||||
where Self : 'static, F : FnMut(T) + Sync + Send + 'static
|
||||
{
|
||||
let x = Arc::new(self);
|
||||
tokio::spawn(async move {
|
||||
rt.spawn(async move {
|
||||
while let Ok(data) = x.recv().await {
|
||||
cb(data)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue