diff options
| author | bors <bors@rust-lang.org> | 2013-12-04 23:26:19 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-12-04 23:26:19 -0800 |
| commit | b5bab85c1a41bcd7758fb8090a3cf3ba20e33b48 (patch) | |
| tree | ca9f9e55e2369c253cedd265d7273553370cfb8d /src/libstd/rt | |
| parent | 10c8409c786b8ee43c00fadfa1be6ebbfc846a91 (diff) | |
| parent | b1705714d5a13e9057db364b685c7cce7cc27982 (diff) | |
| download | rust-b5bab85c1a41bcd7758fb8090a3cf3ba20e33b48.tar.gz rust-b5bab85c1a41bcd7758fb8090a3cf3ba20e33b48.zip | |
auto merge of #10796 : kballard/rust/revert-new-naming, r=alexcrichton
Rename the `*::init()` functions back to `*::new()`, since `new` is not going to become a keyword.
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/deque.rs | 28 | ||||
| -rw-r--r-- | src/libstd/rt/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/sched.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rt/test.rs | 8 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/libstd/rt/deque.rs b/src/libstd/rt/deque.rs index bf3a061096a..3595587f342 100644 --- a/src/libstd/rt/deque.rs +++ b/src/libstd/rt/deque.rs @@ -26,7 +26,7 @@ //! //! use std::rt::deque::BufferPool; //! -//! let mut pool = BufferPool::init(); +//! let mut pool = BufferPool::new(); //! let (mut worker, mut stealer) = pool.deque(); //! //! // Only the worker may push/pop @@ -139,14 +139,14 @@ struct Buffer<T> { impl<T: Send> BufferPool<T> { /// Allocates a new buffer pool which in turn can be used to allocate new /// deques. - pub fn init() -> BufferPool<T> { + pub fn new() -> BufferPool<T> { BufferPool { pool: Exclusive::new(~[]) } } /// Allocates a new work-stealing deque which will send/receiving memory to /// and from this buffer pool. pub fn deque(&mut self) -> (Worker<T>, Stealer<T>) { - let (a, b) = UnsafeArc::new2(Deque::init(self.clone())); + let (a, b) = UnsafeArc::new2(Deque::new(self.clone())); (Worker { deque: a }, Stealer { deque: b }) } @@ -155,7 +155,7 @@ impl<T: Send> BufferPool<T> { self.pool.with(|pool| { match pool.iter().position(|x| x.size() >= (1 << bits)) { Some(i) => pool.remove(i), - None => ~Buffer::init(bits) + None => ~Buffer::new(bits) } }) } @@ -221,7 +221,7 @@ impl<T: Send> Clone for Stealer<T> { // personally going to heavily comment what's going on here. impl<T: Send> Deque<T> { - fn init(mut pool: BufferPool<T>) -> Deque<T> { + fn new(mut pool: BufferPool<T>) -> Deque<T> { let buf = pool.alloc(MIN_BITS); Deque { bottom: AtomicInt::new(0), @@ -341,7 +341,7 @@ impl<T: Send> Drop for Deque<T> { } impl<T: Send> Buffer<T> { - unsafe fn init(log_size: int) -> Buffer<T> { + unsafe fn new(log_size: int) -> Buffer<T> { let size = (1 << log_size) * mem::size_of::<T>(); let buffer = libc::malloc(size as libc::size_t); assert!(!buffer.is_null()); @@ -375,7 +375,7 @@ impl<T: Send> Buffer<T> { // Again, unsafe because this has incredibly dubious ownership violations. // It is assumed that this buffer is immediately dropped. unsafe fn resize(&self, b: int, t: int, delta: int) -> Buffer<T> { - let mut buf = Buffer::init(self.log_size + delta); + let mut buf = Buffer::new(self.log_size + delta); for i in range(t, b) { buf.put(i, self.get(i)); } @@ -406,7 +406,7 @@ mod tests { #[test] fn smoke() { - let mut pool = BufferPool::init(); + let mut pool = BufferPool::new(); let (mut w, mut s) = pool.deque(); assert_eq!(w.pop(), None); assert_eq!(s.steal(), Empty); @@ -421,7 +421,7 @@ mod tests { #[test] fn stealpush() { static AMT: int = 100000; - let mut pool = BufferPool::<int>::init(); + let mut pool = BufferPool::<int>::new(); let (mut w, s) = pool.deque(); let t = do Thread::start { let mut s = s; @@ -447,7 +447,7 @@ mod tests { #[test] fn stealpush_large() { static AMT: int = 100000; - let mut pool = BufferPool::<(int, int)>::init(); + let mut pool = BufferPool::<(int, int)>::new(); let (mut w, s) = pool.deque(); let t = do Thread::start { let mut s = s; @@ -509,7 +509,7 @@ mod tests { #[test] fn run_stampede() { - let mut pool = BufferPool::<~int>::init(); + let mut pool = BufferPool::<~int>::new(); let (w, s) = pool.deque(); stampede(w, s, 8, 10000); } @@ -517,7 +517,7 @@ mod tests { #[test] fn many_stampede() { static AMT: uint = 4; - let mut pool = BufferPool::<~int>::init(); + let mut pool = BufferPool::<~int>::new(); let threads = range(0, AMT).map(|_| { let (w, s) = pool.deque(); do Thread::start { @@ -536,7 +536,7 @@ mod tests { static NTHREADS: int = 8; static mut DONE: AtomicBool = INIT_ATOMIC_BOOL; static mut HITS: AtomicUint = INIT_ATOMIC_UINT; - let mut pool = BufferPool::<int>::init(); + let mut pool = BufferPool::<int>::new(); let (mut w, s) = pool.deque(); let threads = range(0, NTHREADS).map(|_| { @@ -595,7 +595,7 @@ mod tests { static AMT: int = 10000; static NTHREADS: int = 4; static mut DONE: AtomicBool = INIT_ATOMIC_BOOL; - let mut pool = BufferPool::<(int, uint)>::init(); + let mut pool = BufferPool::<(int, uint)>::new(); let (mut w, s) = pool.deque(); let (threads, hits) = vec::unzip(range(0, NTHREADS).map(|_| { diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index d1268d85a43..3d0222cefae 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -281,7 +281,7 @@ fn run_(main: proc(), use_main_sched: bool) -> int { // Create a work queue for each scheduler, ntimes. Create an extra // for the main thread if that flag is set. We won't steal from it. - let mut pool = deque::BufferPool::init(); + let mut pool = deque::BufferPool::new(); let arr = vec::from_fn(nscheds, |_| pool.deque()); let (workers, stealers) = vec::unzip(arr.move_iter()); diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs index 8c46a8eff39..1cd8fcf589d 100644 --- a/src/libstd/rt/sched.rs +++ b/src/libstd/rt/sched.rs @@ -1002,7 +1002,7 @@ mod test { do run_in_bare_thread { let sleepers = SleeperList::new(); - let mut pool = BufferPool::init(); + let mut pool = BufferPool::new(); let (normal_worker, normal_stealer) = pool.deque(); let (special_worker, special_stealer) = pool.deque(); let queues = ~[normal_stealer, special_stealer]; @@ -1177,7 +1177,7 @@ mod test { do run_in_bare_thread { stress_factor().times(|| { let sleepers = SleeperList::new(); - let mut pool = BufferPool::init(); + let mut pool = BufferPool::new(); let (worker, stealer) = pool.deque(); let mut sched = ~Scheduler::new( diff --git a/src/libstd/rt/test.rs b/src/libstd/rt/test.rs index 51ad37a2583..2ab543a4c36 100644 --- a/src/libstd/rt/test.rs +++ b/src/libstd/rt/test.rs @@ -36,7 +36,7 @@ use vec::{OwnedVector, MutableVector, ImmutableVector}; pub fn new_test_uv_sched() -> Scheduler { - let mut pool = BufferPool::init(); + let mut pool = BufferPool::new(); let (worker, stealer) = pool.deque(); let mut sched = Scheduler::new(new_event_loop(), @@ -51,7 +51,7 @@ pub fn new_test_uv_sched() -> Scheduler { } pub fn new_test_sched() -> Scheduler { - let mut pool = BufferPool::init(); + let mut pool = BufferPool::new(); let (worker, stealer) = pool.deque(); let mut sched = Scheduler::new(basic::event_loop(), @@ -228,7 +228,7 @@ pub fn run_in_mt_newsched_task(f: proc()) { let mut handles = ~[]; let mut scheds = ~[]; - let mut pool = BufferPool::<~Task>::init(); + let mut pool = BufferPool::<~Task>::new(); let workers = range(0, nthreads).map(|_| pool.deque()); let (workers, stealers) = vec::unzip(workers); @@ -381,7 +381,7 @@ pub fn next_test_unix() -> Path { if cfg!(unix) { os::tmpdir().join(rand::task_rng().gen_ascii_str(20)) } else { - Path::init(r"\\.\pipe\" + rand::task_rng().gen_ascii_str(20)) + Path::new(r"\\.\pipe\" + rand::task_rng().gen_ascii_str(20)) } } |
