spawn handler futures on the reactor
This commit is contained in:
parent
885e96a495
commit
971a386ca0
1 changed files with 4 additions and 1 deletions
|
@ -141,8 +141,11 @@ impl IrcReactor {
|
||||||
&mut self, client: IrcClient, mut handler: F
|
&mut self, client: IrcClient, mut handler: F
|
||||||
) where F: FnMut(&IrcClient, Message) -> U + 'static,
|
) where F: FnMut(&IrcClient, Message) -> U + 'static,
|
||||||
U: IntoFuture<Item = (), Error = error::IrcError> + 'static {
|
U: IntoFuture<Item = (), Error = error::IrcError> + 'static {
|
||||||
|
let handle = self.inner.handle().clone();
|
||||||
self.handlers.push(Box::new(client.stream().for_each(move |message| {
|
self.handlers.push(Box::new(client.stream().for_each(move |message| {
|
||||||
handler(&client, message)
|
handle.spawn(handler(&client, message).into_future().map_err(|_| (())));
|
||||||
|
|
||||||
|
Ok(())
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue