Merge pull request #173 from dgriffen/dev/dgriffen/non-sequential-handler

spawn handler futures on the reactor
This commit is contained in:
Aaron Weiss 2019-01-14 10:16:43 -05:00 committed by GitHub
commit 48b5adf33b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -141,8 +141,11 @@ impl IrcReactor {
&mut self, client: IrcClient, mut handler: F
) where F: FnMut(&IrcClient, Message) -> U + '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| {
handler(&client, message)
handle.spawn(handler(&client, message).into_future().map_err(|_| (())));
Ok(())
})));
}