mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 00:34:06 +00:00
std: Fix a doc example on io::signal
This also makes the listener struct sendable again by explicitly putting the Send bound on the relevant Rtio object. cc #13352
This commit is contained in:
parent
0651d2790c
commit
137e648edd
@ -23,6 +23,7 @@ use clone::Clone;
|
||||
use comm::{Sender, Receiver, channel};
|
||||
use io;
|
||||
use iter::Iterator;
|
||||
use kinds::Send;
|
||||
use mem::drop;
|
||||
use option::{Some, None};
|
||||
use result::{Ok, Err};
|
||||
@ -63,25 +64,23 @@ pub enum Signum {
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// ```rust,no_run
|
||||
/// # #![allow(unused_must_use)]
|
||||
/// use std::io::signal::{Listener, Interrupt};
|
||||
///
|
||||
/// let mut listener = Listener::new();
|
||||
/// listener.register(Interrupt);
|
||||
///
|
||||
/// spawn({
|
||||
/// loop {
|
||||
/// match listener.rx.recv() {
|
||||
/// Interrupt => println!("Got Interrupt'ed"),
|
||||
/// _ => (),
|
||||
/// }
|
||||
/// loop {
|
||||
/// match listener.rx.recv() {
|
||||
/// Interrupt => println!("Got Interrupt'ed"),
|
||||
/// _ => (),
|
||||
/// }
|
||||
/// });
|
||||
///
|
||||
/// }
|
||||
/// ```
|
||||
pub struct Listener {
|
||||
/// A map from signums to handles to keep the handles in memory
|
||||
handles: ~[(Signum, ~RtioSignal)],
|
||||
handles: ~[(Signum, ~RtioSignal:Send)],
|
||||
/// This is where all the handles send signums, which are received by
|
||||
/// the clients from the receiver.
|
||||
tx: Sender<Signum>,
|
||||
|
Loading…
Reference in New Issue
Block a user