Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I/O resources lazily bind to reactor. #160

Merged
merged 1 commit into from
Feb 28, 2018

Commits on Feb 27, 2018

  1. I/O resources lazily bind to reactor.

    This patch makes a significant change to how I/O resources bind to a
    reactor. Currently, an I/O resource (TCP, UDP, PollEvented) will bind
    itself with a reactor upon creation.
    
    First, some history.
    
    Originally, tokio-core required that I/O resources be explicitly
    associated with a reactor upon creation by passing in a `&Handle`. Tokio
    reform introduced a default reactor. If I/O resources do not specify a
    reactor upon creation, then the default reactor is used.
    
    However, futures tend to favor being lazy. Creating a future should do
    no work, instead it is defining a computation to be performed once the
    future is executed. Binding an I/O resource with a reactor on creation
    goes against this pattern.
    
    This patch fixes this by allowing I/O resources to lazily bind to a
    reactor. An explicit `&Handle` can still be used on creation, but if no
    reactor is specified, then the default reactor is used. However, this
    binding happens during execution time (read / write) and not creation.
    carllerche committed Feb 27, 2018
    Configuration menu
    Copy the full SHA
    4c9d3da View commit details
    Browse the repository at this point in the history