From 982d1b5a0d7580cf4723ea45b210dfa5ae712ad6 Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Sat, 27 Jan 2018 15:18:15 +0100 Subject: [PATCH] Added a function to access the tokio reactor handle in IrcReactor. --- src/client/reactor.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/client/reactor.rs b/src/client/reactor.rs index 0d4847e..54d75d2 100644 --- a/src/client/reactor.rs +++ b/src/client/reactor.rs @@ -2,7 +2,7 @@ use futures::{Future, Stream}; use futures::future; -use tokio_core::reactor::Core; +use tokio_core::reactor::{Core, Handle}; use client::data::Config; use client::server::{IrcServer, IrcServerFuture, Server}; @@ -64,6 +64,13 @@ impl IrcReactor { self.handlers.push(Box::new(future)) } + /// Returns a handle to the internal event loop. This is a sort of escape hatch that allows you + /// to take more control over what runs on the reactor using `tokio`. This can be used for + /// sharing this reactor with some elements of other libraries. + pub fn inner_handle(&self) -> Handle { + self.inner.handle() + } + /// Consumes all registered handlers and futures, and runs them. When using /// `register_server_with_handler`, this will block indefinitely (until failure occurs) as it /// will simply continue to process new, incoming messages for each server that was registered.