Revert "Convert libstd to use the Drop trait"
This reverts commit 28c7a25151.
This commit is contained in:
@@ -217,10 +217,7 @@ fn check_poison(is_mutex: bool, failed: bool) {
|
||||
#[doc(hidden)]
|
||||
struct PoisonOnFail {
|
||||
failed: &mut bool,
|
||||
}
|
||||
|
||||
impl PoisonOnFail : Drop {
|
||||
fn finalize() {
|
||||
drop {
|
||||
/* assert !*self.failed; -- might be false in case of cond.wait() */
|
||||
if task::failing() { *self.failed = true; }
|
||||
}
|
||||
|
||||
@@ -55,10 +55,7 @@ pub struct Arena {
|
||||
priv mut head: Chunk,
|
||||
priv mut pod_head: Chunk,
|
||||
priv mut chunks: @List<Chunk>,
|
||||
}
|
||||
|
||||
impl Arena : Drop {
|
||||
fn finalize() {
|
||||
drop {
|
||||
unsafe {
|
||||
destroy_chunk(&self.head);
|
||||
for list::each(self.chunks) |chunk| {
|
||||
|
||||
@@ -39,10 +39,7 @@ pub enum CVec<T> {
|
||||
|
||||
struct DtorRes {
|
||||
dtor: Option<fn@()>,
|
||||
}
|
||||
|
||||
impl DtorRes : Drop {
|
||||
fn finalize() {
|
||||
drop {
|
||||
match self.dtor {
|
||||
option::None => (),
|
||||
option::Some(f) => f()
|
||||
|
||||
@@ -23,12 +23,10 @@ use cast::copy_lifetime;
|
||||
#[doc = "The future type"]
|
||||
pub struct Future<A> {
|
||||
/*priv*/ mut state: FutureState<A>,
|
||||
}
|
||||
|
||||
// FIXME(#2829) -- futures should not be copyable, because they close
|
||||
// over fn~'s that have pipes and so forth within!
|
||||
impl<A> Future<A> : Drop {
|
||||
fn finalize() {}
|
||||
// FIXME(#2829) -- futures should not be copyable, because they close
|
||||
// over fn~'s that have pipes and so forth within!
|
||||
drop {}
|
||||
}
|
||||
|
||||
priv enum FutureState<A> {
|
||||
|
||||
@@ -27,10 +27,7 @@ extern mod rustrt {
|
||||
*/
|
||||
struct TcpSocket {
|
||||
socket_data: @TcpSocketData,
|
||||
}
|
||||
|
||||
impl TcpSocket : Drop {
|
||||
fn finalize() {
|
||||
drop {
|
||||
unsafe {
|
||||
tear_down_socket_data(self.socket_data)
|
||||
}
|
||||
|
||||
@@ -1133,10 +1133,7 @@ mod big_tests {
|
||||
val: uint,
|
||||
key: fn(@uint),
|
||||
|
||||
}
|
||||
|
||||
impl LVal : Drop {
|
||||
fn finalize() {
|
||||
drop {
|
||||
let x = unsafe { task::local_data::local_data_get(self.key) };
|
||||
match x {
|
||||
Some(@y) => {
|
||||
|
||||
@@ -150,12 +150,7 @@ impl &Sem<~[mut Waitqueue]> {
|
||||
#[doc(hidden)]
|
||||
struct SemRelease {
|
||||
sem: &Sem<()>,
|
||||
}
|
||||
|
||||
impl SemRelease : Drop {
|
||||
fn finalize() {
|
||||
self.sem.release();
|
||||
}
|
||||
drop { self.sem.release(); }
|
||||
}
|
||||
|
||||
fn SemRelease(sem: &r/Sem<()>) -> SemRelease/&r {
|
||||
@@ -167,12 +162,7 @@ fn SemRelease(sem: &r/Sem<()>) -> SemRelease/&r {
|
||||
#[doc(hidden)]
|
||||
struct SemAndSignalRelease {
|
||||
sem: &Sem<~[mut Waitqueue]>,
|
||||
}
|
||||
|
||||
impl SemAndSignalRelease : Drop {
|
||||
fn finalize() {
|
||||
self.sem.release();
|
||||
}
|
||||
drop { self.sem.release(); }
|
||||
}
|
||||
|
||||
fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>)
|
||||
@@ -183,9 +173,7 @@ fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>)
|
||||
}
|
||||
|
||||
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
|
||||
pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]> }
|
||||
|
||||
impl Condvar : Drop { fn finalize() {} }
|
||||
pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]>, drop { } }
|
||||
|
||||
impl &Condvar {
|
||||
/**
|
||||
@@ -254,18 +242,13 @@ impl &Condvar {
|
||||
// bounded in when it gets released, this shouldn't hang forever.
|
||||
struct SemAndSignalReacquire {
|
||||
sem: &Sem<~[mut Waitqueue]>,
|
||||
}
|
||||
|
||||
impl SemAndSignalReacquire : Drop {
|
||||
fn finalize() {
|
||||
unsafe {
|
||||
drop unsafe {
|
||||
// Needs to succeed, instead of itself dying.
|
||||
do task::unkillable {
|
||||
self.sem.acquire();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn SemAndSignalReacquire(sem: &r/Sem<~[mut Waitqueue]>)
|
||||
-> SemAndSignalReacquire/&r {
|
||||
@@ -598,11 +581,7 @@ impl &RWlock {
|
||||
#[doc(hidden)]
|
||||
struct RWlockReleaseRead {
|
||||
lock: &RWlock,
|
||||
}
|
||||
|
||||
impl RWlockReleaseRead : Drop {
|
||||
fn finalize() {
|
||||
unsafe {
|
||||
drop unsafe {
|
||||
do task::unkillable {
|
||||
let mut last_reader = false;
|
||||
do self.lock.state.with |state| {
|
||||
@@ -619,7 +598,6 @@ impl RWlockReleaseRead : Drop {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn RWlockReleaseRead(lock: &r/RWlock) -> RWlockReleaseRead/&r {
|
||||
@@ -632,11 +610,7 @@ fn RWlockReleaseRead(lock: &r/RWlock) -> RWlockReleaseRead/&r {
|
||||
#[doc(hidden)]
|
||||
struct RWlockReleaseDowngrade {
|
||||
lock: &RWlock,
|
||||
}
|
||||
|
||||
impl RWlockReleaseDowngrade : Drop {
|
||||
fn finalize() {
|
||||
unsafe {
|
||||
drop unsafe {
|
||||
do task::unkillable {
|
||||
let mut writer_or_last_reader = false;
|
||||
do self.lock.state.with |state| {
|
||||
@@ -648,8 +622,7 @@ impl RWlockReleaseDowngrade : Drop {
|
||||
writer_or_last_reader = true;
|
||||
state.read_mode = false;
|
||||
} else {
|
||||
// Case 2: Writer downgraded & was not the last
|
||||
// reader
|
||||
// Case 2: Writer downgraded & was not the last reader
|
||||
}
|
||||
} else {
|
||||
// Case 3: Writer did not downgrade
|
||||
@@ -661,7 +634,6 @@ impl RWlockReleaseDowngrade : Drop {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r {
|
||||
@@ -671,11 +643,9 @@ fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r {
|
||||
}
|
||||
|
||||
/// The "write permission" token used for rwlock.write_downgrade().
|
||||
pub struct RWlockWriteMode { /* priv */ lock: &RWlock }
|
||||
impl RWlockWriteMode : Drop { fn finalize() {} }
|
||||
pub struct RWlockWriteMode { /* priv */ lock: &RWlock, drop { } }
|
||||
/// The "read permission" token used for rwlock.write_downgrade().
|
||||
pub struct RWlockReadMode { priv lock: &RWlock }
|
||||
impl RWlockReadMode : Drop { fn finalize() {} }
|
||||
pub struct RWlockReadMode { priv lock: &RWlock, drop { } }
|
||||
|
||||
impl &RWlockWriteMode {
|
||||
/// Access the pre-downgrade rwlock in write mode.
|
||||
@@ -984,12 +954,7 @@ mod tests {
|
||||
}
|
||||
struct SendOnFailure {
|
||||
c: pipes::Chan<()>,
|
||||
}
|
||||
|
||||
impl SendOnFailure : Drop {
|
||||
fn finalize() {
|
||||
self.c.send(());
|
||||
}
|
||||
drop { self.c.send(()); }
|
||||
}
|
||||
|
||||
fn SendOnFailure(c: pipes::Chan<()>) -> SendOnFailure {
|
||||
|
||||
@@ -13,10 +13,7 @@ pub struct ThreadPool<T> {
|
||||
channels: ~[Chan<Msg<T>>],
|
||||
mut next_index: uint,
|
||||
|
||||
}
|
||||
|
||||
impl<T> ThreadPool<T> {
|
||||
fn finalize() {
|
||||
drop {
|
||||
for self.channels.each |channel| {
|
||||
channel.send(Quit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user