std: Remove struct ctors
This commit is contained in:
parent
268850f67b
commit
eb0cf3a715
|
@ -223,13 +223,18 @@ fn check_poison(is_mutex: bool, failed: bool) {
|
|||
#[doc(hidden)]
|
||||
struct PoisonOnFail {
|
||||
failed: &mut bool;
|
||||
new(failed: &mut bool) { self.failed = failed; }
|
||||
drop {
|
||||
/* assert !*self.failed; -- might be false in case of cond.wait() */
|
||||
if task::failing() { *self.failed = true; }
|
||||
}
|
||||
}
|
||||
|
||||
fn PoisonOnFail(failed: &r/mut bool) -> PoisonOnFail/&r {
|
||||
PoisonOnFail {
|
||||
failed: failed
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* R/W lock protected ARC
|
||||
****************************************************************************/
|
||||
|
|
|
@ -44,7 +44,6 @@ enum CVec<T> {
|
|||
|
||||
struct DtorRes {
|
||||
let dtor: Option<fn@()>;
|
||||
new(dtor: Option<fn@()>) { self.dtor = dtor; }
|
||||
drop {
|
||||
match self.dtor {
|
||||
option::None => (),
|
||||
|
@ -53,6 +52,12 @@ struct DtorRes {
|
|||
}
|
||||
}
|
||||
|
||||
fn DtorRes(dtor: Option<fn@()>) -> DtorRes {
|
||||
DtorRes {
|
||||
dtor: dtor
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Section: Introduction forms
|
||||
*/
|
||||
|
|
|
@ -40,7 +40,6 @@ extern mod rustrt {
|
|||
*/
|
||||
struct TcpSocket {
|
||||
let socket_data: @TcpSocketData;
|
||||
new(socket_data: @TcpSocketData) { self.socket_data = socket_data; }
|
||||
drop {
|
||||
unsafe {
|
||||
tear_down_socket_data(self.socket_data)
|
||||
|
@ -48,6 +47,12 @@ struct TcpSocket {
|
|||
}
|
||||
}
|
||||
|
||||
fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
|
||||
TcpSocket {
|
||||
socket_data: socket_data
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A buffered wrapper for `net::tcp::tcp_socket`
|
||||
*
|
||||
|
@ -56,7 +61,12 @@ struct TcpSocket {
|
|||
*/
|
||||
struct TcpSocketBuf {
|
||||
let data: @TcpBufferedSocketData;
|
||||
new(data: @TcpBufferedSocketData) { self.data = data; }
|
||||
}
|
||||
|
||||
fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf {
|
||||
TcpSocketBuf {
|
||||
data: data
|
||||
}
|
||||
}
|
||||
|
||||
/// Contains raw, string-based, error information returned from libuv
|
||||
|
|
|
@ -154,16 +154,28 @@ impl &Sem<~[mut Waitqueue]> {
|
|||
#[doc(hidden)]
|
||||
struct SemRelease {
|
||||
sem: &Sem<()>;
|
||||
new(sem: &Sem<()>) { self.sem = sem; }
|
||||
drop { self.sem.release(); }
|
||||
}
|
||||
|
||||
fn SemRelease(sem: &r/Sem<()>) -> SemRelease/&r {
|
||||
SemRelease {
|
||||
sem: sem
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
struct SemAndSignalRelease {
|
||||
sem: &Sem<~[mut Waitqueue]>;
|
||||
new(sem: &Sem<~[mut Waitqueue]>) { self.sem = sem; }
|
||||
drop { self.sem.release(); }
|
||||
}
|
||||
|
||||
fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>)
|
||||
-> SemAndSignalRelease/&r {
|
||||
SemAndSignalRelease {
|
||||
sem: sem
|
||||
}
|
||||
}
|
||||
|
||||
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
|
||||
struct Condvar { priv sem: &Sem<~[mut Waitqueue]>; drop { } }
|
||||
|
||||
|
@ -234,7 +246,6 @@ impl &Condvar {
|
|||
// bounded in when it gets released, this shouldn't hang forever.
|
||||
struct SemAndSignalReacquire {
|
||||
sem: &Sem<~[mut Waitqueue]>;
|
||||
new(sem: &Sem<~[mut Waitqueue]>) { self.sem = sem; }
|
||||
drop unsafe {
|
||||
// Needs to succeed, instead of itself dying.
|
||||
do task::unkillable {
|
||||
|
@ -242,6 +253,14 @@ impl &Condvar {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn SemAndSignalReacquire(sem: &r/Sem<~[mut Waitqueue]>)
|
||||
-> SemAndSignalReacquire/&r {
|
||||
SemAndSignalReacquire {
|
||||
sem: sem
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Wake up a blocked task. Returns false if there was no blocked task.
|
||||
|
@ -567,7 +586,6 @@ impl &RWlock {
|
|||
#[doc(hidden)]
|
||||
struct RWlockReleaseRead {
|
||||
lock: &RWlock;
|
||||
new(lock: &RWlock) { self.lock = lock; }
|
||||
drop unsafe {
|
||||
do task::unkillable {
|
||||
let mut last_reader = false;
|
||||
|
@ -587,11 +605,16 @@ struct RWlockReleaseRead {
|
|||
}
|
||||
}
|
||||
|
||||
fn RWlockReleaseRead(lock: &r/RWlock) -> RWlockReleaseRead/&r {
|
||||
RWlockReleaseRead {
|
||||
lock: lock
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(#3136) should go inside of downgrade()
|
||||
#[doc(hidden)]
|
||||
struct RWlockReleaseDowngrade {
|
||||
lock: &RWlock;
|
||||
new(lock: &RWlock) { self.lock = lock; }
|
||||
drop unsafe {
|
||||
do task::unkillable {
|
||||
let mut writer_or_last_reader = false;
|
||||
|
@ -618,6 +641,12 @@ struct RWlockReleaseDowngrade {
|
|||
}
|
||||
}
|
||||
|
||||
fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r {
|
||||
RWlockReleaseDowngrade {
|
||||
lock: lock
|
||||
}
|
||||
}
|
||||
|
||||
/// The "write permission" token used for rwlock.write_downgrade().
|
||||
struct RWlockWriteMode { /* priv */ lock: &RWlock; drop { } }
|
||||
/// The "read permission" token used for rwlock.write_downgrade().
|
||||
|
@ -929,9 +958,14 @@ mod tests {
|
|||
}
|
||||
struct SendOnFailure {
|
||||
c: pipes::Chan<()>;
|
||||
new(+c: pipes::Chan<()>) { self.c = c; }
|
||||
drop { self.c.send(()); }
|
||||
}
|
||||
|
||||
fn SendOnFailure(+c: pipes::Chan<()>) -> SendOnFailure {
|
||||
SendOnFailure {
|
||||
c: c
|
||||
}
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn test_mutex_cond_signal_on_0() {
|
||||
|
|
Loading…
Reference in New Issue