Added a function to spawn arbitrary futures on a reactor (i.e. opt-in "full" tokio support).

This commit is contained in:
Aaron Weiss 2018-01-24 12:13:33 +01:00
parent 233eab6969
commit ab16c865bb
No known key found for this signature in database
GPG key ID: 047D32DF25DC22EF

View file

@ -42,6 +42,12 @@ impl IrcReactor {
})));
}
pub fn register_future<F>(
&mut self, future: F
) where F: Future<Item = (), Error = error::Error> + 'static {
self.handlers.push(Box::new(future))
}
pub fn run(&mut self) -> error::Result<()> {
let mut handlers = Vec::new();
while let Some(handler) = self.handlers.pop() {