Skip to content

Commit b9b0ed5

Browse files
committed
green: Switch field privacy as necessary
1 parent eb08e8f commit b9b0ed5

File tree

8 files changed

+41
-40
lines changed

8 files changed

+41
-40
lines changed

src/libgreen/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ use std::raw;
2222
// then misalign the regs again.
2323
pub struct Context {
2424
/// Hold the registers while the task or scheduler is suspended
25-
priv regs: ~Registers,
25+
regs: ~Registers,
2626
/// Lower bound and upper bound for the stack
27-
priv stack_bounds: Option<(uint, uint)>,
27+
stack_bounds: Option<(uint, uint)>,
2828
}
2929

3030
pub type InitFn = extern "C" fn(uint, *(), *()) -> !;

src/libgreen/coroutine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ pub struct Coroutine {
2222
///
2323
/// Servo needs this to be public in order to tell SpiderMonkey
2424
/// about the stack bounds.
25-
current_stack_segment: Stack,
25+
pub current_stack_segment: Stack,
2626

2727
/// Always valid if the task is alive and not running.
28-
saved_context: Context
28+
pub saved_context: Context
2929
}
3030

3131
impl Coroutine {

src/libgreen/lib.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ pub fn run(event_loop_factory: fn() -> ~rtio::EventLoop:Send,
296296
/// Configuration of how an M:N pool of schedulers is spawned.
297297
pub struct PoolConfig {
298298
/// The number of schedulers (OS threads) to spawn into this M:N pool.
299-
threads: uint,
299+
pub threads: uint,
300300
/// A factory function used to create new event loops. If this is not
301301
/// specified then the default event loop factory is used.
302-
event_loop_factory: fn() -> ~rtio::EventLoop:Send,
302+
pub event_loop_factory: fn() -> ~rtio::EventLoop:Send,
303303
}
304304

305305
impl PoolConfig {
@@ -316,17 +316,17 @@ impl PoolConfig {
316316
/// A structure representing a handle to a pool of schedulers. This handle is
317317
/// used to keep the pool alive and also reap the status from the pool.
318318
pub struct SchedPool {
319-
priv id: uint,
320-
priv threads: ~[Thread<()>],
321-
priv handles: ~[SchedHandle],
322-
priv stealers: ~[deque::Stealer<~task::GreenTask>],
323-
priv next_friend: uint,
324-
priv stack_pool: StackPool,
325-
priv deque_pool: deque::BufferPool<~task::GreenTask>,
326-
priv sleepers: SleeperList,
327-
priv factory: fn() -> ~rtio::EventLoop:Send,
328-
priv task_state: TaskState,
329-
priv tasks_done: Receiver<()>,
319+
id: uint,
320+
threads: ~[Thread<()>],
321+
handles: ~[SchedHandle],
322+
stealers: ~[deque::Stealer<~task::GreenTask>],
323+
next_friend: uint,
324+
stack_pool: StackPool,
325+
deque_pool: deque::BufferPool<~task::GreenTask>,
326+
sleepers: SleeperList,
327+
factory: fn() -> ~rtio::EventLoop:Send,
328+
task_state: TaskState,
329+
tasks_done: Receiver<()>,
330330
}
331331

332332
/// This is an internal state shared among a pool of schedulers. This is used to

src/libgreen/message_queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ pub fn queue<T: Send>() -> (Consumer<T>, Producer<T>) {
2323
}
2424

2525
pub struct Producer<T> {
26-
priv inner: UnsafeArc<mpsc::Queue<T>>,
26+
inner: UnsafeArc<mpsc::Queue<T>>,
2727
}
2828

2929
pub struct Consumer<T> {
30-
priv inner: UnsafeArc<mpsc::Queue<T>>,
30+
inner: UnsafeArc<mpsc::Queue<T>>,
3131
}
3232

3333
impl<T: Send> Consumer<T> {

src/libgreen/sched.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ pub struct Scheduler {
3939
/// ID number of the pool that this scheduler is a member of. When
4040
/// reawakening green tasks, this is used to ensure that tasks aren't
4141
/// reawoken on the wrong pool of schedulers.
42-
pool_id: uint,
42+
pub pool_id: uint,
43+
/// The pool of stacks that this scheduler has cached
44+
pub stack_pool: StackPool,
45+
/// Bookkeeping for the number of tasks which are currently running around
46+
/// inside this pool of schedulers
47+
pub task_state: TaskState,
4348
/// There are N work queues, one per scheduler.
4449
work_queue: deque::Worker<~GreenTask>,
4550
/// Work queues for the other schedulers. These are created by
@@ -64,7 +69,6 @@ pub struct Scheduler {
6469
/// A flag to indicate we've received the shutdown message and should
6570
/// no longer try to go to sleep, but exit instead.
6671
no_sleep: bool,
67-
stack_pool: StackPool,
6872
/// The scheduler runs on a special task. When it is not running
6973
/// it is stored here instead of the work queue.
7074
sched_task: Option<~GreenTask>,
@@ -87,9 +91,6 @@ pub struct Scheduler {
8791
/// A flag to tell the scheduler loop it needs to do some stealing
8892
/// in order to introduce randomness as part of a yield
8993
steal_for_yield: bool,
90-
/// Bookkeeping for the number of tasks which are currently running around
91-
/// inside this pool of schedulers
92-
task_state: TaskState,
9394

9495
// n.b. currently destructors of an object are run in top-to-bottom in order
9596
// of field declaration. Due to its nature, the pausable idle callback
@@ -99,7 +100,7 @@ pub struct Scheduler {
99100
// destroyed before it's actually destroyed.
100101

101102
/// The event loop used to drive the scheduler and perform I/O
102-
event_loop: ~EventLoop:Send,
103+
pub event_loop: ~EventLoop:Send,
103104
}
104105

105106
/// An indication of how hard to work on a given operation, the difference
@@ -893,9 +894,9 @@ pub enum SchedMessage {
893894
}
894895

895896
pub struct SchedHandle {
896-
priv remote: ~RemoteCallback:Send,
897-
priv queue: msgq::Producer<SchedMessage>,
898-
sched_id: uint
897+
remote: ~RemoteCallback:Send,
898+
queue: msgq::Producer<SchedMessage>,
899+
pub sched_id: uint
899900
}
900901

901902
impl SchedHandle {

src/libgreen/sleeper_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::sync::mpmc_bounded_queue::Queue;
1616
use sched::SchedHandle;
1717

1818
pub struct SleeperList {
19-
priv q: Queue<SchedHandle>,
19+
q: Queue<SchedHandle>,
2020
}
2121

2222
impl SleeperList {

src/libgreen/stack.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use std::libc;
1515

1616
/// A task's stack. The name "Stack" is a vestige of segmented stacks.
1717
pub struct Stack {
18-
priv buf: MemoryMap,
19-
priv min_size: uint,
20-
priv valgrind_id: libc::c_uint,
18+
buf: MemoryMap,
19+
min_size: uint,
20+
valgrind_id: libc::c_uint,
2121
}
2222

2323
// Try to use MAP_STACK on platforms that support it (it's what we're doing
@@ -126,7 +126,7 @@ impl Drop for Stack {
126126
pub struct StackPool {
127127
// Ideally this would be some datastructure that preserved ordering on
128128
// Stack.min_size.
129-
priv stacks: ~[Stack],
129+
stacks: ~[Stack],
130130
}
131131

132132
impl StackPool {

src/libgreen/task.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,32 @@ pub struct GreenTask {
4242
/// context and the stack that this task owns. This field is optional to
4343
/// relinquish ownership back to a scheduler to recycle stacks at a later
4444
/// date.
45-
coroutine: Option<Coroutine>,
45+
pub coroutine: Option<Coroutine>,
4646

4747
/// Optional handle back into the home sched pool of this task. This field
4848
/// is lazily initialized.
49-
handle: Option<SchedHandle>,
49+
pub handle: Option<SchedHandle>,
5050

5151
/// Slot for maintaining ownership of a scheduler. If a task is running,
5252
/// this value will be Some(sched) where the task is running on "sched".
53-
sched: Option<~Scheduler>,
53+
pub sched: Option<~Scheduler>,
5454

5555
/// Temporary ownership slot of a std::rt::task::Task object. This is used
5656
/// to squirrel that libstd task away while we're performing green task
5757
/// operations.
58-
task: Option<~Task>,
58+
pub task: Option<~Task>,
5959

6060
/// Dictates whether this is a sched task or a normal green task
61-
task_type: TaskType,
61+
pub task_type: TaskType,
6262

6363
/// Home pool that this task was spawned into. This field is lazily
6464
/// initialized until when the task is initially scheduled, and is used to
6565
/// make sure that tasks are always woken up in the correct pool of
6666
/// schedulers.
67-
pool_id: uint,
67+
pub pool_id: uint,
6868

6969
// See the comments in the scheduler about why this is necessary
70-
nasty_deschedule_lock: NativeMutex,
70+
pub nasty_deschedule_lock: NativeMutex,
7171
}
7272

7373
pub enum TaskType {

0 commit comments

Comments
 (0)