[−][src]Struct tokio_core::reactor::Core
An event loop.
The event loop is the main source of blocking in an application which drives all other I/O events and notifications happening. Each event loop can have multiple handles pointing to it, each of which can then be used to create various I/O objects to interact with the event loop in interesting ways.
Methods
impl Core
[src]
impl Core
pub fn new() -> Result<Core>
[src]
pub fn new() -> Result<Core>
Creates a new event loop, returning any error that happened during the creation.
pub fn handle(&self) -> Handle
[src]
pub fn handle(&self) -> Handle
Returns a handle to this event loop which cannot be sent across threads but can be used as a proxy to the event loop itself.
Handles are cloneable and clones always refer to the same event loop. This handle is typically passed into functions that create I/O objects to bind them to this event loop.
pub fn runtime(&self) -> &Runtime
[src]
pub fn runtime(&self) -> &Runtime
Returns a reference to the runtime backing the instance
This provides access to the newer features of Tokio.
pub fn remote(&self) -> Remote
[src]
pub fn remote(&self) -> Remote
Generates a remote handle to this event loop which can be used to spawn tasks from other threads into this event loop.
pub fn run<F>(&mut self, f: F) -> Result<F::Item, F::Error> where
F: Future,
[src]
pub fn run<F>(&mut self, f: F) -> Result<F::Item, F::Error> where
F: Future,
Runs a future until completion, driving the event loop while we're otherwise waiting for the future to complete.
This function will begin executing the event loop and will finish once
the provided future is resolved. Note that the future argument here
crucially does not require the 'static
nor Send
bounds. As a result
the future will be "pinned" to not only this thread but also this stack
frame.
This function will return the value that the future resolves to once the future has finished. If the future never resolves then this function will never return.
Panics
This method will not catch panics from polling the future f
. If
the future panics then it's the responsibility of the caller to catch
that panic and handle it as appropriate.
pub fn turn(&mut self, max_wait: Option<Duration>)
[src]
pub fn turn(&mut self, max_wait: Option<Duration>)
Performs one iteration of the event loop, blocking on waiting for events
for at most max_wait
(forever if None
).
It only makes sense to call this method if you've previously spawned a future onto this event loop.
loop { lp.turn(None) }
is equivalent to calling run
with an
empty future (one that never finishes).
pub fn id(&self) -> CoreId
[src]
pub fn id(&self) -> CoreId
Get the ID of this loop
Trait Implementations
impl Debug for Core
[src]
impl Debug for Core
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<F> Executor<F> for Core where
F: Future<Item = (), Error = ()> + 'static,
[src]
impl<F> Executor<F> for Core where
F: Future<Item = (), Error = ()> + 'static,
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
[src]
impl<T> Erased for T