(index<- )
./
libgreen
/
sleeper_list.rs
git branch: * master 5200215 auto merge of #14035 : alexcrichton/rust/experimental, r=huonw
modified: Wed Apr 9 17:27:02 2014
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
//! Maintains a shared list of sleeping schedulers. Schedulers
12
//! use this to wake each other up.
13
14
use
std::sync::mpmc_bounded_queue::Queue
;
15
16
use
sched::SchedHandle
;
17
18
pub
struct
SleeperList
{
19
q:
Queue<
SchedHandle
>
,
20
}
21
22
impl
SleeperList
{
23
pub
fn
new
()
->
SleeperList
{
24
SleeperList
{
q:
Queue::with_capacity
(
8
*
1024
)
}
25
}
26
27
pub
fn
push
(
&mut self
,
value
:
SchedHandle
)
{
28
assert!
(
self
.q
.push
(
value
))
29
}
30
31
pub
fn
pop
(
&mut self
)
->
Option<
SchedHandle
>
{
32
self
.q
.pop
()
33
}
34
35
pub
fn
casual_pop
(
&mut self
)
->
Option<
SchedHandle
>
{
36
self
.q
.pop
()
37
}
38
}
39
40
impl
Clone
for
SleeperList
{
41
fn
clone
(
&self
)
->
SleeperList
{
42
SleeperList
{
43
q:
self
.q
.clone
()
44
}
45
}
46
}
libgreen/sleeper_list.rs:17:1-17:1 -struct- definition:
pub struct SleeperList {
q: Queue<SchedHandle>,
}
references:- 10
23:
pub fn new() -> SleeperList {
24:
SleeperList{q: Queue::with_capacity(8*1024)}
25:
}
--
41:
fn clone(&self) -> SleeperList {
42:
SleeperList {
43:
q: self.q.clone()
libgreen/lib.rs:
366:
deque_pool: deque::BufferPool<Box<task::GreenTask>>,
367:
sleepers: SleeperList,
368:
factory: fn() -> Box<rtio::EventLoop:Send>,
libgreen/sched.rs:
141:
work_queues: Vec<deque::Stealer<Box<GreenTask>>>,
142:
sleeper_list: SleeperList,
143:
run_anything: bool,