diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-08-29 14:45:25 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-08-29 15:34:38 -0700 |
| commit | aab4d6b8d73f029d178c3ac055152f57c7233995 (patch) | |
| tree | 4bcf9b989e5dd2be2b8b3086c5365b7115765a9e /src/libstd | |
| parent | 6c5c835a1dccd55287bbd81564d74a009497be57 (diff) | |
std: Camel case some constructors
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/arc.rs | 42 | ||||
| -rw-r--r-- | src/libstd/c_vec.rs | 4 | ||||
| -rw-r--r-- | src/libstd/ebml.rs | 5 | ||||
| -rw-r--r-- | src/libstd/sync.rs | 62 |
4 files changed, 56 insertions, 57 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 70e33576365..89cdb2a674d 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -10,13 +10,13 @@ import unsafe::{SharedMutableState, shared_mutable_state, clone_shared_mutable_state, unwrap_shared_mutable_state, get_shared_mutable_state, get_shared_immutable_state}; import sync; -import sync::{Mutex, mutex, mutex_with_condvars, - RWlock, rwlock, rwlock_with_condvars}; +import sync::{Mutex, mutex_with_condvars, + RWlock, rwlock_with_condvars}; -export ARC, arc, clone, get; +export ARC, clone, get; export Condvar; -export MutexARC, mutex_arc, mutex_arc_with_condvars, unwrap_mutex_arc; -export RWARC, rw_arc, rw_arc_with_condvars, RWWriteMode, RWReadMode; +export MutexARC, mutex_arc_with_condvars, unwrap_mutex_arc; +export RWARC, rw_arc_with_condvars, RWWriteMode, RWReadMode; export unwrap_rw_arc; /// As sync::condvar, a mechanism for unlock-and-descheduling and signalling. @@ -73,7 +73,7 @@ impl &Condvar { struct ARC<T: const send> { x: SharedMutableState<T>; } /// Create an atomically reference counted wrapper. -fn arc<T: const send>(+data: T) -> ARC<T> { +fn ARC<T: const send>(+data: T) -> ARC<T> { ARC { x: unsafe { shared_mutable_state(data) } } } @@ -120,7 +120,7 @@ struct MutexARCInner<T: send> { lock: Mutex; failed: bool; data: T; } struct MutexARC<T: send> { x: SharedMutableState<MutexARCInner<T>>; } /// Create a mutex-protected ARC with the supplied data. -fn mutex_arc<T: send>(+user_data: T) -> MutexARC<T> { +fn MutexARC<T: send>(+user_data: T) -> MutexARC<T> { mutex_arc_with_condvars(user_data, 1) } /** @@ -249,7 +249,7 @@ struct RWARC<T: const send> { } /// Create a reader/writer ARC with the supplied data. -fn rw_arc<T: const send>(+user_data: T) -> RWARC<T> { +fn RWARC<T: const send>(+user_data: T) -> RWARC<T> { rw_arc_with_condvars(user_data, 1) } /** @@ -445,7 +445,7 @@ mod tests { #[test] fn manually_share_arc() { let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - let arc_v = arc::arc(v); + let arc_v = arc::ARC(v); let (c, p) = pipes::stream(); @@ -469,7 +469,7 @@ mod tests { #[test] fn test_mutex_arc_condvar() { - let arc = ~mutex_arc(false); + let arc = ~MutexARC(false); let arc2 = ~arc.clone(); let (c,p) = pipes::oneshot(); let (c,p) = (~mut Some(c), ~mut Some(p)); @@ -491,7 +491,7 @@ mod tests { } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_arc_condvar_poison() { - let arc = ~mutex_arc(1); + let arc = ~MutexARC(1); let arc2 = ~arc.clone(); let (c,p) = pipes::stream(); @@ -512,7 +512,7 @@ mod tests { } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_mutex_arc_poison() { - let arc = ~mutex_arc(1); + let arc = ~MutexARC(1); let arc2 = ~arc.clone(); do task::try { do arc2.access |one| { @@ -525,7 +525,7 @@ mod tests { } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_mutex_arc_unwrap_poison() { - let arc = mutex_arc(1); + let arc = MutexARC(1); let arc2 = ~(&arc).clone(); let (c,p) = pipes::stream(); do task::spawn { @@ -540,7 +540,7 @@ mod tests { } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_rw_arc_poison_wr() { - let arc = ~rw_arc(1); + let arc = ~RWARC(1); let arc2 = ~arc.clone(); do task::try { do arc2.write |one| { @@ -553,7 +553,7 @@ mod tests { } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_rw_arc_poison_ww() { - let arc = ~rw_arc(1); + let arc = ~RWARC(1); let arc2 = ~arc.clone(); do task::try { do arc2.write |one| { @@ -566,7 +566,7 @@ mod tests { } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_rw_arc_poison_dw() { - let arc = ~rw_arc(1); + let arc = ~RWARC(1); let arc2 = ~arc.clone(); do task::try { do arc2.write_downgrade |write_mode| { @@ -581,7 +581,7 @@ mod tests { } #[test] #[ignore(cfg(windows))] fn test_rw_arc_no_poison_rr() { - let arc = ~rw_arc(1); + let arc = ~RWARC(1); let arc2 = ~arc.clone(); do task::try { do arc2.read |one| { @@ -594,7 +594,7 @@ mod tests { } #[test] #[ignore(cfg(windows))] fn test_rw_arc_no_poison_rw() { - let arc = ~rw_arc(1); + let arc = ~RWARC(1); let arc2 = ~arc.clone(); do task::try { do arc2.read |one| { @@ -607,7 +607,7 @@ mod tests { } #[test] #[ignore(cfg(windows))] fn test_rw_arc_no_poison_dr() { - let arc = ~rw_arc(1); + let arc = ~RWARC(1); let arc2 = ~arc.clone(); do task::try { do arc2.write_downgrade |write_mode| { @@ -623,7 +623,7 @@ mod tests { } #[test] fn test_rw_arc() { - let arc = ~rw_arc(0); + let arc = ~RWARC(0); let arc2 = ~arc.clone(); let (c,p) = pipes::stream(); @@ -662,7 +662,7 @@ mod tests { // (4) tells writer and all other readers to contend as it downgrades. // (5) Writer attempts to set state back to 42, while downgraded task // and all reader tasks assert that it's 31337. - let arc = ~rw_arc(0); + let arc = ~RWARC(0); // Reader tasks let mut reader_convos = ~[]; diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index afbc9826134..6af7f71cb30 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -28,7 +28,7 @@ */ export CVec; -export c_vec, c_vec_with_dtor; +export CVec, c_vec_with_dtor; export get, set; export len; export ptr; @@ -66,7 +66,7 @@ struct DtorRes { * * base - A foreign pointer to a buffer * * len - The number of elements in the buffer */ -unsafe fn c_vec<T>(base: *mut T, len: uint) -> CVec<T> { +unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> { return CVecCtor({ base: base, len: len, diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 5b7f7553ddd..068ad608e68 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -6,7 +6,6 @@ import core::Option; import option::{Some, None}; -export doc; export Doc; export doc_at; export maybe_get_doc; @@ -75,7 +74,7 @@ fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { } else { error!("vint too big"); fail; } } -fn doc(data: @~[u8]) -> Doc { +fn Doc(data: @~[u8]) -> Doc { return {data: data, start: 0u, end: vec::len::<u8>(*data)}; } @@ -619,7 +618,7 @@ fn test_option_int() { let mbuf = io::mem_buffer(); let ebml_w = ebml::Writer(io::mem_buffer_writer(mbuf)); serialize_0(ebml_w, v); - let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf)); + let ebml_doc = ebml::Doc(@io::mem_buffer_buf(mbuf)); let deser = ebml_deserializer(ebml_doc); let v1 = deserialize_0(deser); debug!("v1 == %?", v1); diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 5e35454da84..acd25bd7c7c 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -8,8 +8,8 @@ * in std. */ -export Condvar, Semaphore, Mutex, mutex, mutex_with_condvars; -export RWlock, rwlock, rwlock_with_condvars, RWlockReadMode, RWlockWriteMode; +export Condvar, Semaphore, Mutex, mutex_with_condvars; +export RWlock, rwlock_with_condvars, RWlockReadMode, RWlockWriteMode; import unsafe::{Exclusive, exclusive}; @@ -362,7 +362,7 @@ impl &Semaphore { struct Mutex { priv sem: Sem<~[mut Waitqueue]>; } /// Create a new mutex, with one associated condvar. -fn mutex() -> Mutex { mutex_with_condvars(1) } +fn Mutex() -> Mutex { mutex_with_condvars(1) } /** * Create a new mutex, with a specified number of associated condvars. This * will allow calling wait_on/signal_on/broadcast_on with condvar IDs between @@ -412,7 +412,7 @@ struct RWlock { } /// Create a new rwlock, with one associated condvar. -fn rwlock() -> RWlock { rwlock_with_condvars(1) } +fn RWlock() -> RWlock { rwlock_with_condvars(1) } /** * Create a new rwlock, with a specified number of associated condvars. @@ -745,7 +745,7 @@ mod tests { // Unsafely achieve shared state, and do the textbook // "load tmp <- ptr; inc tmp; store ptr <- tmp" dance. let (c,p) = pipes::stream(); - let m = ~mutex(); + let m = ~Mutex(); let m2 = ~m.clone(); let sharedstate = ~0; let ptr = ptr::addr_of(*sharedstate); @@ -773,7 +773,7 @@ mod tests { } #[test] fn test_mutex_cond_wait() { - let m = ~mutex(); + let m = ~Mutex(); // Child wakes up parent do m.lock_cond |cond| { @@ -805,7 +805,7 @@ mod tests { } #[cfg(test)] fn test_mutex_cond_broadcast_helper(num_waiters: uint) { - let m = ~mutex(); + let m = ~Mutex(); let mut ports = ~[]; for num_waiters.times { @@ -840,7 +840,7 @@ mod tests { } #[test] fn test_mutex_cond_no_waiter() { - let m = ~mutex(); + let m = ~Mutex(); let m2 = ~m.clone(); do task::try { do m.lock_cond |_x| { } @@ -852,7 +852,7 @@ mod tests { #[test] #[ignore(cfg(windows))] fn test_mutex_killed_simple() { // Mutex must get automatically unlocked if failed/killed within. - let m = ~mutex(); + let m = ~Mutex(); let m2 = ~m.clone(); let result: result::Result<(),()> = do task::try { @@ -868,7 +868,7 @@ mod tests { fn test_mutex_killed_cond() { // Getting killed during cond wait must not corrupt the mutex while // unwinding (e.g. double unlock). - let m = ~mutex(); + let m = ~Mutex(); let m2 = ~m.clone(); let result: result::Result<(),()> = do task::try { @@ -892,7 +892,7 @@ mod tests { } #[test] #[ignore(cfg(windows))] fn test_mutex_killed_broadcast() { - let m = ~mutex(); + let m = ~Mutex(); let m2 = ~m.clone(); let (c,p) = pipes::stream(); @@ -936,7 +936,7 @@ mod tests { #[test] fn test_mutex_cond_signal_on_0() { // Tests that signal_on(0) is equivalent to signal(). - let m = ~mutex(); + let m = ~Mutex(); do m.lock_cond |cond| { let m2 = ~m.clone(); do task::spawn { @@ -1040,17 +1040,17 @@ mod tests { } #[test] fn test_rwlock_readers_wont_modify_the_data() { - test_rwlock_exclusion(~rwlock(), Read, Write); - test_rwlock_exclusion(~rwlock(), Write, Read); - test_rwlock_exclusion(~rwlock(), Read, Downgrade); - test_rwlock_exclusion(~rwlock(), Downgrade, Read); + test_rwlock_exclusion(~RWlock(), Read, Write); + test_rwlock_exclusion(~RWlock(), Write, Read); + test_rwlock_exclusion(~RWlock(), Read, Downgrade); + test_rwlock_exclusion(~RWlock(), Downgrade, Read); } #[test] fn test_rwlock_writers_and_writers() { - test_rwlock_exclusion(~rwlock(), Write, Write); - test_rwlock_exclusion(~rwlock(), Write, Downgrade); - test_rwlock_exclusion(~rwlock(), Downgrade, Write); - test_rwlock_exclusion(~rwlock(), Downgrade, Downgrade); + test_rwlock_exclusion(~RWlock(), Write, Write); + test_rwlock_exclusion(~RWlock(), Write, Downgrade); + test_rwlock_exclusion(~RWlock(), Downgrade, Write); + test_rwlock_exclusion(~RWlock(), Downgrade, Downgrade); } #[cfg(test)] fn test_rwlock_handshake(+x: ~RWlock, mode1: RWlockMode, @@ -1084,32 +1084,32 @@ mod tests { } #[test] fn test_rwlock_readers_and_readers() { - test_rwlock_handshake(~rwlock(), Read, Read, false); + test_rwlock_handshake(~RWlock(), Read, Read, false); // The downgrader needs to get in before the reader gets in, otherwise // they cannot end up reading at the same time. - test_rwlock_handshake(~rwlock(), DowngradeRead, Read, false); - test_rwlock_handshake(~rwlock(), Read, DowngradeRead, true); + test_rwlock_handshake(~RWlock(), DowngradeRead, Read, false); + test_rwlock_handshake(~RWlock(), Read, DowngradeRead, true); // Two downgrade_reads can never both end up reading at the same time. } #[test] fn test_rwlock_downgrade_unlock() { // Tests that downgrade can unlock the lock in both modes - let x = ~rwlock(); + let x = ~RWlock(); do lock_rwlock_in_mode(x, Downgrade) { } test_rwlock_handshake(x, Read, Read, false); - let y = ~rwlock(); + let y = ~RWlock(); do lock_rwlock_in_mode(y, DowngradeRead) { } test_rwlock_exclusion(y, Write, Write); } #[test] fn test_rwlock_read_recursive() { - let x = ~rwlock(); + let x = ~RWlock(); do x.read { do x.read { } } } #[test] fn test_rwlock_cond_wait() { // As test_mutex_cond_wait above. - let x = ~rwlock(); + let x = ~RWlock(); // Child wakes up parent do x.write_cond |cond| { @@ -1154,7 +1154,7 @@ mod tests { x.write_cond(blk) } } - let x = ~rwlock(); + let x = ~RWlock(); let mut ports = ~[]; for num_waiters.times { @@ -1193,7 +1193,7 @@ mod tests { #[cfg(test)] #[ignore(cfg(windows))] fn rwlock_kill_helper(mode1: RWlockMode, mode2: RWlockMode) { // Mutex must get automatically unlocked if failed/killed within. - let x = ~rwlock(); + let x = ~RWlock(); let x2 = ~x.clone(); let result: result::Result<(),()> = do task::try { @@ -1231,8 +1231,8 @@ mod tests { #[test] #[should_fail] #[ignore(cfg(windows))] fn test_rwlock_downgrade_cant_swap() { // Tests that you can't downgrade with a different rwlock's token. - let x = ~rwlock(); - let y = ~rwlock(); + let x = ~RWlock(); + let y = ~RWlock(); do x.write_downgrade |xwrite| { let mut xopt = Some(xwrite); do y.write_downgrade |_ywrite| { |
