about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-01 09:37:39 -0700
committerbors <bors@rust-lang.org>2013-06-01 09:37:39 -0700
commit44af5064d0ac3d45223f1555b299f10fd4902f5c (patch)
tree33a4db59bd936a73594ca144e809b6074d6ccef3 /src/libstd/rt
parentb8391ccea0b2e2718a4d4ef999e9f03583c7ddea (diff)
parent5fb254695b4db9af3d8e33577fae28ae9f7006c5 (diff)
downloadrust-44af5064d0ac3d45223f1555b299f10fd4902f5c.tar.gz
rust-44af5064d0ac3d45223f1555b299f10fd4902f5c.zip
auto merge of #6871 : pcwalton/rust/de-pub-impl, r=pcwalton
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/context.rs8
-rw-r--r--src/libstd/rt/sched.rs51
-rw-r--r--src/libstd/rt/stack.rs10
-rw-r--r--src/libstd/rt/thread.rs4
-rw-r--r--src/libstd/rt/uv/idle.rs15
-rw-r--r--src/libstd/rt/uv/mod.rs17
-rw-r--r--src/libstd/rt/uv/net.rs34
-rw-r--r--src/libstd/rt/uv/uvio.rs11
-rw-r--r--src/libstd/rt/uvio.rs10
-rw-r--r--src/libstd/rt/work_queue.rs12
10 files changed, 85 insertions, 87 deletions
diff --git a/src/libstd/rt/context.rs b/src/libstd/rt/context.rs
index 0d011ce42ba..d5ca8473cee 100644
--- a/src/libstd/rt/context.rs
+++ b/src/libstd/rt/context.rs
@@ -27,8 +27,8 @@ pub struct Context {
     regs: ~Registers
 }
 
-pub impl Context {
-    fn empty() -> Context {
+impl Context {
+    pub fn empty() -> Context {
         Context {
             start: None,
             regs: new_regs()
@@ -36,7 +36,7 @@ pub impl Context {
     }
 
     /// Create a new context that will resume execution by running ~fn()
-    fn new(start: ~fn(), stack: &mut StackSegment) -> Context {
+    pub fn new(start: ~fn(), stack: &mut StackSegment) -> Context {
         // XXX: Putting main into a ~ so it's a thin pointer and can
         // be passed to the spawn function.  Another unfortunate
         // allocation
@@ -71,7 +71,7 @@ pub impl Context {
     saving the registers values of the executing thread to a Context
     then loading the registers from a previously saved Context.
     */
-    fn swap(out_context: &mut Context, in_context: &Context) {
+    pub fn swap(out_context: &mut Context, in_context: &Context) {
         let out_regs: &mut Registers = match out_context {
             &Context { regs: ~ref mut r, _ } => r
         };
diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs
index 2d9cdaddc84..064eb63afc6 100644
--- a/src/libstd/rt/sched.rs
+++ b/src/libstd/rt/sched.rs
@@ -57,11 +57,10 @@ enum CleanupJob {
     GiveTask(~Coroutine, UnsafeTaskReceiver)
 }
 
-pub impl Scheduler {
+impl Scheduler {
+    pub fn in_task_context(&self) -> bool { self.current_task.is_some() }
 
-    fn in_task_context(&self) -> bool { self.current_task.is_some() }
-
-    fn new(event_loop: ~EventLoopObject) -> Scheduler {
+    pub fn new(event_loop: ~EventLoopObject) -> Scheduler {
 
         // Lazily initialize the runtime TLS key
         local_ptr::init_tls_key();
@@ -80,7 +79,7 @@ pub impl Scheduler {
     // the scheduler itself doesn't have to call event_loop.run.
     // That will be important for embedding the runtime into external
     // event loops.
-    fn run(~self) -> ~Scheduler {
+    pub fn run(~self) -> ~Scheduler {
         assert!(!self.in_task_context());
 
         let mut self_sched = self;
@@ -107,7 +106,7 @@ pub impl Scheduler {
     /// Pushes the task onto the work stealing queue and tells the event loop
     /// to run it later. Always use this instead of pushing to the work queue
     /// directly.
-    fn enqueue_task(&mut self, task: ~Coroutine) {
+    pub fn enqueue_task(&mut self, task: ~Coroutine) {
         self.work_queue.push(task);
         self.event_loop.callback(resume_task_from_queue);
 
@@ -119,7 +118,7 @@ pub impl Scheduler {
 
     // * Scheduler-context operations
 
-    fn resume_task_from_queue(~self) {
+    pub fn resume_task_from_queue(~self) {
         assert!(!self.in_task_context());
 
         rtdebug!("looking in work queue for task to schedule");
@@ -141,7 +140,7 @@ pub impl Scheduler {
 
     /// Called by a running task to end execution, after which it will
     /// be recycled by the scheduler for reuse in a new task.
-    fn terminate_current_task(~self) {
+    pub fn terminate_current_task(~self) {
         assert!(self.in_task_context());
 
         rtdebug!("ending running task");
@@ -156,7 +155,7 @@ pub impl Scheduler {
         abort!("control reached end of task");
     }
 
-    fn schedule_new_task(~self, task: ~Coroutine) {
+    pub fn schedule_new_task(~self, task: ~Coroutine) {
         assert!(self.in_task_context());
 
         do self.switch_running_tasks_and_then(task) |last_task| {
@@ -167,7 +166,7 @@ pub impl Scheduler {
         }
     }
 
-    fn schedule_task(~self, task: ~Coroutine) {
+    pub fn schedule_task(~self, task: ~Coroutine) {
         assert!(self.in_task_context());
 
         do self.switch_running_tasks_and_then(task) |last_task| {
@@ -180,7 +179,7 @@ pub impl Scheduler {
 
     // Core scheduling ops
 
-    fn resume_task_immediately(~self, task: ~Coroutine) {
+    pub fn resume_task_immediately(~self, task: ~Coroutine) {
         let mut this = self;
         assert!(!this.in_task_context());
 
@@ -218,7 +217,7 @@ pub impl Scheduler {
     /// The closure here is a *stack* closure that lives in the
     /// running task.  It gets transmuted to the scheduler's lifetime
     /// and called while the task is blocked.
-    fn deschedule_running_task_and_then(~self, f: &fn(~Coroutine)) {
+    pub fn deschedule_running_task_and_then(~self, f: &fn(~Coroutine)) {
         let mut this = self;
         assert!(this.in_task_context());
 
@@ -248,7 +247,9 @@ pub impl Scheduler {
     /// Switch directly to another task, without going through the scheduler.
     /// You would want to think hard about doing this, e.g. if there are
     /// pending I/O events it would be a bad idea.
-    fn switch_running_tasks_and_then(~self, next_task: ~Coroutine, f: &fn(~Coroutine)) {
+    pub fn switch_running_tasks_and_then(~self,
+                                         next_task: ~Coroutine,
+                                         f: &fn(~Coroutine)) {
         let mut this = self;
         assert!(this.in_task_context());
 
@@ -279,12 +280,12 @@ pub impl Scheduler {
 
     // * Other stuff
 
-    fn enqueue_cleanup_job(&mut self, job: CleanupJob) {
+    pub fn enqueue_cleanup_job(&mut self, job: CleanupJob) {
         assert!(self.cleanup_job.is_none());
         self.cleanup_job = Some(job);
     }
 
-    fn run_cleanup_job(&mut self) {
+    pub fn run_cleanup_job(&mut self) {
         rtdebug!("running cleanup job");
 
         assert!(self.cleanup_job.is_some());
@@ -305,9 +306,9 @@ pub impl Scheduler {
     /// callers should first arrange for that task to be located in the
     /// Scheduler's current_task slot and set up the
     /// post-context-switch cleanup job.
-    fn get_contexts<'a>(&'a mut self) -> (&'a mut Context,
-                                          Option<&'a mut Context>,
-                                          Option<&'a mut Context>) {
+    pub fn get_contexts<'a>(&'a mut self) -> (&'a mut Context,
+                                              Option<&'a mut Context>,
+                                              Option<&'a mut Context>) {
         let last_task = match self.cleanup_job {
             Some(GiveTask(~ref task, _)) => {
                 Some(task)
@@ -349,14 +350,14 @@ pub struct Coroutine {
     task: ~Task
 }
 
-pub impl Coroutine {
-    fn new(stack_pool: &mut StackPool, start: ~fn()) -> Coroutine {
+impl Coroutine {
+    pub fn new(stack_pool: &mut StackPool, start: ~fn()) -> Coroutine {
         Coroutine::with_task(stack_pool, ~Task::new(), start)
     }
 
-    fn with_task(stack_pool: &mut StackPool,
-                  task: ~Task,
-                  start: ~fn()) -> Coroutine {
+    pub fn with_task(stack_pool: &mut StackPool,
+                     task: ~Task,
+                     start: ~fn()) -> Coroutine {
         let start = Coroutine::build_start_wrapper(start);
         let mut stack = stack_pool.take_segment(MIN_STACK_SIZE);
         // NB: Context holds a pointer to that ~fn
@@ -368,7 +369,7 @@ pub impl Coroutine {
         };
     }
 
-    priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
+    fn build_start_wrapper(start: ~fn()) -> ~fn() {
         // XXX: The old code didn't have this extra allocation
         let wrapper: ~fn() = || {
             // This is the first code to execute after the initial
@@ -391,7 +392,7 @@ pub impl Coroutine {
     }
 
     /// Destroy the task and try to reuse its components
-    fn recycle(~self, stack_pool: &mut StackPool) {
+    pub fn recycle(~self, stack_pool: &mut StackPool) {
         match self {
             ~Coroutine {current_stack_segment, _} => {
                 stack_pool.give_segment(current_stack_segment);
diff --git a/src/libstd/rt/stack.rs b/src/libstd/rt/stack.rs
index ec56e65931c..fa4b8f30f4e 100644
--- a/src/libstd/rt/stack.rs
+++ b/src/libstd/rt/stack.rs
@@ -19,8 +19,8 @@ pub struct StackSegment {
     valgrind_id: c_uint
 }
 
-pub impl StackSegment {
-    fn new(size: uint) -> StackSegment {
+impl StackSegment {
+    pub fn new(size: uint) -> StackSegment {
         unsafe {
             // Crate a block of uninitialized values
             let mut stack = vec::with_capacity(size);
@@ -38,12 +38,12 @@ pub impl StackSegment {
     }
 
     /// Point to the low end of the allocated stack
-    fn start(&self) -> *uint {
-      vec::raw::to_ptr(self.buf) as *uint
+    pub fn start(&self) -> *uint {
+        vec::raw::to_ptr(self.buf) as *uint
     }
 
     /// Point one word beyond the high end of the allocated stack
-    fn end(&self) -> *uint {
+    pub fn end(&self) -> *uint {
         vec::raw::to_ptr(self.buf).offset(self.buf.len()) as *uint
     }
 }
diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs
index 0f1ae09bd94..bc290191310 100644
--- a/src/libstd/rt/thread.rs
+++ b/src/libstd/rt/thread.rs
@@ -19,8 +19,8 @@ pub struct Thread {
     raw_thread: *raw_thread
 }
 
-pub impl Thread {
-    fn start(main: ~fn()) -> Thread {
+impl Thread {
+    pub fn start(main: ~fn()) -> Thread {
         fn substart(main: &~fn()) -> *raw_thread {
             unsafe { rust_raw_thread_start(main) }
         }
diff --git a/src/libstd/rt/uv/idle.rs b/src/libstd/rt/uv/idle.rs
index 2cf0b5c4872..e1def9ffd50 100644
--- a/src/libstd/rt/uv/idle.rs
+++ b/src/libstd/rt/uv/idle.rs
@@ -17,8 +17,8 @@ use rt::uv::status_to_maybe_uv_error;
 pub struct IdleWatcher(*uvll::uv_idle_t);
 impl Watcher for IdleWatcher { }
 
-pub impl IdleWatcher {
-    fn new(loop_: &mut Loop) -> IdleWatcher {
+impl IdleWatcher {
+    pub fn new(loop_: &mut Loop) -> IdleWatcher {
         unsafe {
             let handle = uvll::idle_new();
             assert!(handle.is_not_null());
@@ -29,7 +29,7 @@ pub impl IdleWatcher {
         }
     }
 
-    fn start(&mut self, cb: IdleCallback) {
+    pub fn start(&mut self, cb: IdleCallback) {
         {
             let data = self.get_watcher_data();
             data.idle_cb = Some(cb);
@@ -48,16 +48,17 @@ pub impl IdleWatcher {
         }
     }
 
-    fn stop(&mut self) {
-        // NB: Not resetting the Rust idle_cb to None here because `stop` is likely
-        // called from *within* the idle callback, causing a use after free
+    pub fn stop(&mut self) {
+        // NB: Not resetting the Rust idle_cb to None here because `stop` is
+        // likely called from *within* the idle callback, causing a use after
+        // free
 
         unsafe {
             assert!(0 == uvll::idle_stop(self.native_handle()));
         }
     }
 
-    fn close(self, cb: NullCallback) {
+    pub fn close(self, cb: NullCallback) {
         {
             let mut this = self;
             let data = this.get_watcher_data();
diff --git a/src/libstd/rt/uv/mod.rs b/src/libstd/rt/uv/mod.rs
index 2bd657fd864..bc968fc3d60 100644
--- a/src/libstd/rt/uv/mod.rs
+++ b/src/libstd/rt/uv/mod.rs
@@ -92,18 +92,18 @@ pub trait NativeHandle<T> {
     pub fn native_handle(&self) -> T;
 }
 
-pub impl Loop {
-    fn new() -> Loop {
+impl Loop {
+    pub fn new() -> Loop {
         let handle = unsafe { uvll::loop_new() };
         assert!(handle.is_not_null());
         NativeHandle::from_native_handle(handle)
     }
 
-    fn run(&mut self) {
+    pub fn run(&mut self) {
         unsafe { uvll::run(self.native_handle()) };
     }
 
-    fn close(&mut self) {
+    pub fn close(&mut self) {
         unsafe { uvll::loop_delete(self.native_handle()) };
     }
 }
@@ -193,9 +193,8 @@ impl<H, W: Watcher + NativeHandle<*H>> WatcherInterop for W {
 
 pub struct UvError(uvll::uv_err_t);
 
-pub impl UvError {
-
-    fn name(&self) -> ~str {
+impl UvError {
+    pub fn name(&self) -> ~str {
         unsafe {
             let inner = match self { &UvError(ref a) => a };
             let name_str = uvll::err_name(inner);
@@ -204,7 +203,7 @@ pub impl UvError {
         }
     }
 
-    fn desc(&self) -> ~str {
+    pub fn desc(&self) -> ~str {
         unsafe {
             let inner = match self { &UvError(ref a) => a };
             let desc_str = uvll::strerror(inner);
@@ -213,7 +212,7 @@ pub impl UvError {
         }
     }
 
-    fn is_eof(&self) -> bool {
+    pub fn is_eof(&self) -> bool {
         self.code == uvll::EOF
     }
 }
diff --git a/src/libstd/rt/uv/net.rs b/src/libstd/rt/uv/net.rs
index 68b871e6b31..563d7fd1e81 100644
--- a/src/libstd/rt/uv/net.rs
+++ b/src/libstd/rt/uv/net.rs
@@ -43,9 +43,8 @@ fn ip4_as_uv_ip4<T>(addr: IpAddr, f: &fn(*sockaddr_in) -> T) -> T {
 pub struct StreamWatcher(*uvll::uv_stream_t);
 impl Watcher for StreamWatcher { }
 
-pub impl StreamWatcher {
-
-    fn read_start(&mut self, alloc: AllocCallback, cb: ReadCallback) {
+impl StreamWatcher {
+    pub fn read_start(&mut self, alloc: AllocCallback, cb: ReadCallback) {
         {
             let data = self.get_watcher_data();
             data.alloc_cb = Some(alloc);
@@ -73,7 +72,7 @@ pub impl StreamWatcher {
         }
     }
 
-    fn read_stop(&mut self) {
+    pub fn read_stop(&mut self) {
         // It would be nice to drop the alloc and read callbacks here,
         // but read_stop may be called from inside one of them and we
         // would end up freeing the in-use environment
@@ -81,7 +80,7 @@ pub impl StreamWatcher {
         unsafe { uvll::read_stop(handle); }
     }
 
-    fn write(&mut self, buf: Buf, cb: ConnectionCallback) {
+    pub fn write(&mut self, buf: Buf, cb: ConnectionCallback) {
         {
             let data = self.get_watcher_data();
             assert!(data.write_cb.is_none());
@@ -110,7 +109,7 @@ pub impl StreamWatcher {
         }
     }
 
-    fn accept(&mut self, stream: StreamWatcher) {
+    pub fn accept(&mut self, stream: StreamWatcher) {
         let self_handle = self.native_handle() as *c_void;
         let stream_handle = stream.native_handle() as *c_void;
         unsafe {
@@ -118,7 +117,7 @@ pub impl StreamWatcher {
         }
     }
 
-    fn close(self, cb: NullCallback) {
+    pub fn close(self, cb: NullCallback) {
         {
             let mut this = self;
             let data = this.get_watcher_data();
@@ -153,8 +152,8 @@ impl NativeHandle<*uvll::uv_stream_t> for StreamWatcher {
 pub struct TcpWatcher(*uvll::uv_tcp_t);
 impl Watcher for TcpWatcher { }
 
-pub impl TcpWatcher {
-    fn new(loop_: &mut Loop) -> TcpWatcher {
+impl TcpWatcher {
+    pub fn new(loop_: &mut Loop) -> TcpWatcher {
         unsafe {
             let handle = malloc_handle(UV_TCP);
             assert!(handle.is_not_null());
@@ -165,7 +164,7 @@ pub impl TcpWatcher {
         }
     }
 
-    fn bind(&mut self, address: IpAddr) -> Result<(), UvError> {
+    pub fn bind(&mut self, address: IpAddr) -> Result<(), UvError> {
         match address {
             Ipv4(*) => {
                 do ip4_as_uv_ip4(address) |addr| {
@@ -183,7 +182,7 @@ pub impl TcpWatcher {
         }
     }
 
-    fn connect(&mut self, address: IpAddr, cb: ConnectionCallback) {
+    pub fn connect(&mut self, address: IpAddr, cb: ConnectionCallback) {
         unsafe {
             assert!(self.get_watcher_data().connect_cb.is_none());
             self.get_watcher_data().connect_cb = Some(cb);
@@ -216,7 +215,7 @@ pub impl TcpWatcher {
         }
     }
 
-    fn listen(&mut self, cb: ConnectionCallback) {
+    pub fn listen(&mut self, cb: ConnectionCallback) {
         {
             let data = self.get_watcher_data();
             assert!(data.connect_cb.is_none());
@@ -240,7 +239,7 @@ pub impl TcpWatcher {
         }
     }
 
-    fn as_stream(&self) -> StreamWatcher {
+    pub fn as_stream(&self) -> StreamWatcher {
         NativeHandle::from_native_handle(self.native_handle() as *uvll::uv_stream_t)
     }
 }
@@ -295,9 +294,8 @@ pub struct WriteRequest(*uvll::uv_write_t);
 
 impl Request for WriteRequest { }
 
-pub impl WriteRequest {
-
-    fn new() -> WriteRequest {
+impl WriteRequest {
+    pub fn new() -> WriteRequest {
         let write_handle = unsafe {
             malloc_req(UV_WRITE)
         };
@@ -306,14 +304,14 @@ pub impl WriteRequest {
         WriteRequest(write_handle)
     }
 
-    fn stream(&self) -> StreamWatcher {
+    pub fn stream(&self) -> StreamWatcher {
         unsafe {
             let stream_handle = uvll::get_stream_handle_from_write_req(self.native_handle());
             NativeHandle::from_native_handle(stream_handle)
         }
     }
 
-    fn delete(self) {
+    pub fn delete(self) {
         unsafe { free_req(self.native_handle() as *c_void) }
     }
 }
diff --git a/src/libstd/rt/uv/uvio.rs b/src/libstd/rt/uv/uvio.rs
index cacd67314eb..1d4f65f1517 100644
--- a/src/libstd/rt/uv/uvio.rs
+++ b/src/libstd/rt/uv/uvio.rs
@@ -33,15 +33,15 @@ pub struct UvEventLoop {
     uvio: UvIoFactory
 }
 
-pub impl UvEventLoop {
-    fn new() -> UvEventLoop {
+impl UvEventLoop {
+    pub fn new() -> UvEventLoop {
         UvEventLoop {
             uvio: UvIoFactory(Loop::new())
         }
     }
 
     /// A convenience constructor
-    fn new_scheduler() -> Scheduler {
+    pub fn new_scheduler() -> Scheduler {
         Scheduler::new(~UvEventLoop::new())
     }
 }
@@ -57,7 +57,6 @@ impl Drop for UvEventLoop {
 }
 
 impl EventLoop for UvEventLoop {
-
     fn run(&mut self) {
         self.uvio.uv_loop().run();
     }
@@ -103,8 +102,8 @@ fn test_callback_run_once() {
 
 pub struct UvIoFactory(Loop);
 
-pub impl UvIoFactory {
-    fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
+impl UvIoFactory {
+    pub fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
         match self { &UvIoFactory(ref mut ptr) => ptr }
     }
 }
diff --git a/src/libstd/rt/uvio.rs b/src/libstd/rt/uvio.rs
index 24bffd8d1cd..c7467364b4d 100644
--- a/src/libstd/rt/uvio.rs
+++ b/src/libstd/rt/uvio.rs
@@ -29,15 +29,15 @@ pub struct UvEventLoop {
     uvio: UvIoFactory
 }
 
-pub impl UvEventLoop {
-    fn new() -> UvEventLoop {
+impl UvEventLoop {
+    pub fn new() -> UvEventLoop {
         UvEventLoop {
             uvio: UvIoFactory(Loop::new())
         }
     }
 
     /// A convenience constructor
-    fn new_scheduler() -> Scheduler {
+    pub fn new_scheduler() -> Scheduler {
         Scheduler::new(~UvEventLoop::new())
     }
 }
@@ -90,8 +90,8 @@ fn test_callback_run_once() {
 
 pub struct UvIoFactory(Loop);
 
-pub impl UvIoFactory {
-    fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
+impl UvIoFactory {
+    pub fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
         match self { &UvIoFactory(ref mut ptr) => ptr }
     }
 }
diff --git a/src/libstd/rt/work_queue.rs b/src/libstd/rt/work_queue.rs
index 4671a45aaea..58d36113f0e 100644
--- a/src/libstd/rt/work_queue.rs
+++ b/src/libstd/rt/work_queue.rs
@@ -21,21 +21,21 @@ pub struct WorkQueue<T> {
     priv queue: ~Exclusive<~[T]>
 }
 
-pub impl<T: Owned> WorkQueue<T> {
-    fn new() -> WorkQueue<T> {
+impl<T: Owned> WorkQueue<T> {
+    pub fn new() -> WorkQueue<T> {
         WorkQueue {
             queue: ~exclusive(~[])
         }
     }
 
-    fn push(&mut self, value: T) {
+    pub fn push(&mut self, value: T) {
         unsafe {
             let value = Cell(value);
             self.queue.with(|q| q.unshift(value.take()) );
         }
     }
 
-    fn pop(&mut self) -> Option<T> {
+    pub fn pop(&mut self) -> Option<T> {
         unsafe {
             do self.queue.with |q| {
                 if !q.is_empty() {
@@ -47,7 +47,7 @@ pub impl<T: Owned> WorkQueue<T> {
         }
     }
 
-    fn steal(&mut self) -> Option<T> {
+    pub fn steal(&mut self) -> Option<T> {
         unsafe {
             do self.queue.with |q| {
                 if !q.is_empty() {
@@ -59,7 +59,7 @@ pub impl<T: Owned> WorkQueue<T> {
         }
     }
 
-    fn is_empty(&self) -> bool {
+    pub fn is_empty(&self) -> bool {
         unsafe {
             self.queue.with_imm(|q| q.is_empty() )
         }