(index<- ) ./libstd/rt/select.rs
1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! Module for private, abstraction-leaking select traits. Wrapped in std::select.
12
13 use rt::kill::BlockedTask;
14 use rt::sched::Scheduler;
15 use option::Option;
16
17 pub trait SelectInner {
18 // Returns true if data was available.
19 fn optimistic_check(&mut self) -> bool;
20 // Returns true if data was available. If so, shall also wake() the task.
21 fn block_on(&mut self, &mut Scheduler, BlockedTask) -> bool;
22 // Returns true if data was available.
23 fn unblock_from(&mut self) -> bool;
24 }
25
26 pub trait SelectPortInner<T> {
27 fn recv_ready(self) -> Option<T>;
28 }
29