Skip to content

Commit 3e2006a

Browse files
committed
Revert "Adding a lock/condition variable to libcore."
This reverts commit e394ebd.
1 parent e3c6e5e commit 3e2006a

File tree

6 files changed

+0
-155
lines changed

6 files changed

+0
-155
lines changed

mk/rt.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ RUNTIME_CS_$(1) := \
7070
rt/rust_cc.cpp \
7171
rt/rust_debug.cpp \
7272
rt/rust_box_annihilator.cpp \
73-
rt/rust_cond_lock.cpp \
7473
rt/memory_region.cpp \
7574
rt/boxed_region.cpp \
7675
rt/arch/$$(HOST_$(1))/context.cpp \

src/libcore/sys.rs

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export min_align_of;
77
export pref_align_of;
88
export refcount;
99
export log_str;
10-
export lock_and_signal, condition, methods;
1110

1211
enum type_desc = {
1312
first_param: **libc::c_int,
@@ -16,20 +15,11 @@ enum type_desc = {
1615
// Remaining fields not listed
1716
};
1817

19-
type rust_cond_lock = *libc::c_void;
20-
2118
#[abi = "cdecl"]
2219
native mod rustrt {
2320
pure fn refcount(t: *()) -> libc::intptr_t;
2421
fn unsupervise();
2522
pure fn shape_log_str(t: *sys::type_desc, data: *()) -> str;
26-
27-
fn rust_create_cond_lock() -> rust_cond_lock;
28-
fn rust_destroy_cond_lock(lock: rust_cond_lock);
29-
fn rust_lock_cond_lock(lock: rust_cond_lock);
30-
fn rust_unlock_cond_lock(lock: rust_cond_lock);
31-
fn rust_wait_cond_lock(lock: rust_cond_lock);
32-
fn rust_signal_cond_lock(lock: rust_cond_lock) -> bool;
3323
}
3424

3525
#[abi = "rust-intrinsic"]
@@ -84,50 +74,8 @@ pure fn log_str<T>(t: T) -> str {
8474
}
8575
}
8676

87-
resource lock_and_signal(lock: rust_cond_lock) {
88-
rustrt::rust_destroy_cond_lock(lock);
89-
}
90-
91-
enum condition {
92-
condition_(rust_cond_lock)
93-
}
94-
95-
resource unlock(lock: rust_cond_lock) {
96-
rustrt::rust_unlock_cond_lock(lock);
97-
}
98-
99-
fn create_lock() -> lock_and_signal {
100-
lock_and_signal(rustrt::rust_create_cond_lock())
101-
}
102-
103-
impl methods for lock_and_signal {
104-
fn lock<T>(f: fn() -> T) -> T {
105-
rustrt::rust_lock_cond_lock(*self);
106-
let _r = unlock(*self);
107-
f()
108-
}
109-
110-
fn lock_cond<T>(f: fn(condition) -> T) -> T {
111-
rustrt::rust_lock_cond_lock(*self);
112-
let _r = unlock(*self);
113-
f(condition_(*self))
114-
}
115-
}
116-
117-
impl methods for condition {
118-
fn wait() {
119-
rustrt::rust_wait_cond_lock(*self);
120-
}
121-
122-
fn signal() -> bool {
123-
rustrt::rust_signal_cond_lock(*self)
124-
}
125-
}
126-
12777
#[cfg(test)]
12878
mod tests {
129-
use std;
130-
import std::arc;
13179

13280
#[test]
13381
fn size_of_basic() {
@@ -173,26 +121,6 @@ mod tests {
173121
assert pref_align_of::<uint>() == 8u;
174122
assert pref_align_of::<*uint>() == 8u;
175123
}
176-
177-
#[test]
178-
fn condition_variable() {
179-
let lock = arc::arc(create_lock());
180-
let lock2 = arc::clone(&lock);
181-
182-
task::spawn {|move lock2|
183-
let lock = arc::get(&lock2);
184-
(*lock).lock_cond {|c|
185-
c.wait();
186-
}
187-
}
188-
189-
let mut signaled = false;
190-
while !signaled {
191-
(*arc::get(&lock)).lock_cond {|c|
192-
signaled = c.signal()
193-
}
194-
}
195-
}
196124
}
197125

198126
// Local Variables:

src/rt/rust_builtin.cpp

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "sync/timer.h"
88
#include "rust_abi.h"
99
#include "rust_port.h"
10-
#include "rust_cond_lock.h"
1110

1211
#include <time.h>
1312

@@ -863,60 +862,6 @@ rust_task_allow_kill() {
863862
task->allow_kill();
864863
}
865864

866-
extern "C" rust_cond_lock*
867-
rust_create_cond_lock() {
868-
return new rust_cond_lock();
869-
}
870-
871-
extern "C" void
872-
rust_destroy_cond_lock(rust_cond_lock *lock) {
873-
delete lock;
874-
}
875-
876-
extern "C" void
877-
rust_lock_cond_lock(rust_cond_lock *lock) {
878-
lock->lock.lock();
879-
}
880-
881-
extern "C" void
882-
rust_unlock_cond_lock(rust_cond_lock *lock) {
883-
lock->lock.unlock();
884-
}
885-
886-
// The next two functions do not use the built in condition variable features
887-
// because the Rust schedule is not aware of them, and they can block the
888-
// scheduler thread.
889-
890-
extern "C" void
891-
rust_wait_cond_lock(rust_cond_lock *lock) {
892-
rust_task *task = rust_get_current_task();
893-
#ifdef DEBUG_LOCKS
894-
assert(lock->lock.lock_held_by_current_thread());
895-
#endif
896-
assert(NULL == lock->waiting);
897-
lock->waiting = task;
898-
lock->lock.unlock();
899-
task->block(lock, "waiting for signal");
900-
lock->lock.lock();
901-
lock->waiting = NULL;
902-
}
903-
904-
extern "C" bool
905-
rust_signal_cond_lock(rust_cond_lock *lock) {
906-
#ifdef DEBUG_LOCKS
907-
assert(lock->lock.lock_held_by_current_thread());
908-
#endif
909-
if(NULL == lock->waiting) {
910-
return false;
911-
}
912-
else {
913-
lock->waiting->wakeup(lock);
914-
return true;
915-
}
916-
}
917-
918-
919-
920865
//
921866
// Local Variables:
922867
// mode: C++

src/rt/rust_cond_lock.cpp

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/rt/rust_cond_lock.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/rt/rustrt.def.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,3 @@ rust_port_drop
163163
rust_port_task
164164
rust_task_inhibit_kill
165165
rust_task_allow_kill
166-
rust_create_cond_lock
167-
rust_destroy_cond_lock
168-
rust_lock_cond_lock
169-
rust_unlock_cond_lock
170-
rust_wait_cond_lock
171-
rust_signal_cond_lock

0 commit comments

Comments
 (0)