# [−][src]Function crossbeam_channel::after

    pub fn after(duration: Duration) -> Receiver<Instant>

Creates a receiver that delivers a message after a certain duration of time.

The channel is bounded with capacity of 1 and never gets disconnected. Exactly one message will be sent into the channel after `duration` elapses. The message is the instant at which it is sent.

# Examples

Using an `after` channel for timeouts:

    use std::time::Duration;
    use crossbeam_channel::{after, unbounded};

    let (s, r) = unbounded::<i32>();
    let timeout = Duration::from_millis(100);

    select! {
        recv(r) -> msg => println!("received {:?}", msg),
        recv(after(timeout)) -> _ => println!("timed out"),
    }

When the message gets sent:

    use std::thread;
    use std::time::{Duration, Instant};
    use crossbeam_channel::after;

    // Converts a number of milliseconds into a `Duration`.
    let ms = |ms| Duration::from_millis(ms);

    // Returns `true` if `a` and `b` are very close `Instant`s.
    let eq = |a, b| a + ms(50) > b && b + ms(50) > a;

    let start = Instant::now();
    let r = after(ms(100));

    thread::sleep(ms(500));

    // This message was sent 100 ms from the start and received 500 ms from the start.
    assert!(eq(r.recv().unwrap(), start + ms(100)));
    assert!(eq(Instant::now(), start + ms(500)));

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)