Struct tokio_core::reactor::Core [] [src]

pub struct Core { /* fields omitted */ }

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]

Creates a new event loop, returning any error that happened during the creation.

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.

Generates a remote handle to this event loop which can be used to spawn tasks from other threads into this event loop.

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 resolve. 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 returns 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.

Similarly, because the provided future will be pinned not only to this thread but also to this task, any attempt to poll the future on a separate thread will result in a panic. That is, calls to task::poll_on must be avoided.

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).