Skip to content

Commit cc9ab2c

Browse files
committed
Remove old comm-based weak task interface
1 parent a3e087c commit cc9ab2c

File tree

5 files changed

+0
-165
lines changed

5 files changed

+0
-165
lines changed

src/libcore/private.rs

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ pub mod weak_task;
3939

4040
extern mod rustrt {
4141
#[legacy_exports];
42-
unsafe fn rust_task_weaken(ch: rust_port_id);
43-
unsafe fn rust_task_unweaken(ch: rust_port_id);
4442

4543
unsafe fn rust_create_little_lock() -> rust_little_lock;
4644
unsafe fn rust_destroy_little_lock(lock: rust_little_lock);
@@ -92,111 +90,11 @@ fn test_run_in_bare_thread() unsafe {
9290
}
9391
}
9492

95-
#[allow(non_camel_case_types)] // runtime type
96-
type rust_port_id = uint;
97-
9893
fn compare_and_swap(address: &mut int, oldval: int, newval: int) -> bool {
9994
let old = rusti::atomic_cxchg(address, oldval, newval);
10095
old == oldval
10196
}
10297

103-
/**
104-
* Convert the current task to a 'weak' task temporarily
105-
*
106-
* As a weak task it will not be counted towards the runtime's set
107-
* of live tasks. When there are no more outstanding live (non-weak) tasks
108-
* the runtime will send an exit message on the provided channel.
109-
*
110-
* This function is super-unsafe. Do not use.
111-
*
112-
* # Safety notes
113-
*
114-
* * Weak tasks must either die on their own or exit upon receipt of
115-
* the exit message. Failure to do so will cause the runtime to never
116-
* exit
117-
* * Tasks must not call `weaken_task` multiple times. This will
118-
* break the kernel's accounting of live tasks.
119-
* * Weak tasks must not be supervised. A supervised task keeps
120-
* a reference to its parent, so the parent will not die.
121-
*/
122-
pub unsafe fn weaken_task(f: fn(oldcomm::Port<()>)) {
123-
let po = oldcomm::Port();
124-
let ch = oldcomm::Chan(&po);
125-
unsafe {
126-
rustrt::rust_task_weaken(cast::reinterpret_cast(&ch));
127-
}
128-
let _unweaken = Unweaken(ch);
129-
f(po);
130-
131-
struct Unweaken {
132-
ch: oldcomm::Chan<()>,
133-
drop unsafe {
134-
rustrt::rust_task_unweaken(cast::reinterpret_cast(&self.ch));
135-
}
136-
}
137-
138-
fn Unweaken(ch: oldcomm::Chan<()>) -> Unweaken {
139-
Unweaken {
140-
ch: ch
141-
}
142-
}
143-
}
144-
145-
#[test]
146-
pub fn test_weaken_task_then_unweaken() {
147-
do task::try {
148-
unsafe {
149-
do weaken_task |_po| {
150-
}
151-
}
152-
};
153-
}
154-
155-
#[test]
156-
pub fn test_weaken_task_wait() {
157-
do task::spawn_unlinked {
158-
unsafe {
159-
do weaken_task |po| {
160-
oldcomm::recv(po);
161-
}
162-
}
163-
}
164-
}
165-
166-
#[test]
167-
pub fn test_weaken_task_stress() {
168-
// Create a bunch of weak tasks
169-
for iter::repeat(100u) {
170-
do task::spawn {
171-
unsafe {
172-
do weaken_task |_po| {
173-
}
174-
}
175-
}
176-
do task::spawn_unlinked {
177-
unsafe {
178-
do weaken_task |po| {
179-
// Wait for it to tell us to die
180-
oldcomm::recv(po);
181-
}
182-
}
183-
}
184-
}
185-
}
186-
187-
#[test]
188-
#[ignore(cfg(windows))]
189-
pub fn test_weaken_task_fail() {
190-
let res = do task::try {
191-
unsafe {
192-
do weaken_task |_po| {
193-
fail;
194-
}
195-
}
196-
};
197-
assert result::is_err(&res);
198-
}
199-
20098
/****************************************************************************
20199
* Shared state & exclusive ARC
202100
****************************************************************************/

src/rt/rust_builtin.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -858,18 +858,6 @@ rust_compare_and_swap_ptr(intptr_t *address,
858858
return sync::compare_and_swap(address, oldval, newval);
859859
}
860860

861-
extern "C" CDECL void
862-
rust_task_weaken(rust_port_id chan) {
863-
rust_task *task = rust_get_current_task();
864-
task->kernel->weaken_task(chan);
865-
}
866-
867-
extern "C" CDECL void
868-
rust_task_unweaken(rust_port_id chan) {
869-
rust_task *task = rust_get_current_task();
870-
task->kernel->unweaken_task(chan);
871-
}
872-
873861
extern "C" void
874862
rust_task_inhibit_kill(rust_task *task) {
875863
task->inhibit_kill();

src/rt/rust_kernel.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -368,30 +368,6 @@ rust_kernel::unregister_task() {
368368
}
369369
}
370370

371-
void
372-
rust_kernel::weaken_task(rust_port_id chan) {
373-
{
374-
scoped_lock with(weak_task_lock);
375-
KLOG_("Weakening task with channel %" PRIdPTR, chan);
376-
weak_task_chans.push_back(chan);
377-
}
378-
inc_weak_task_count();
379-
}
380-
381-
void
382-
rust_kernel::unweaken_task(rust_port_id chan) {
383-
dec_weak_task_count();
384-
{
385-
scoped_lock with(weak_task_lock);
386-
KLOG_("Unweakening task with channel %" PRIdPTR, chan);
387-
std::vector<rust_port_id>::iterator iter =
388-
std::find(weak_task_chans.begin(), weak_task_chans.end(), chan);
389-
if (iter != weak_task_chans.end()) {
390-
weak_task_chans.erase(iter);
391-
}
392-
}
393-
}
394-
395371
void
396372
rust_kernel::inc_weak_task_count() {
397373
uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks);
@@ -407,23 +383,6 @@ rust_kernel::dec_weak_task_count() {
407383
KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
408384
}
409385

410-
void
411-
rust_kernel::end_weak_tasks() {
412-
std::vector<rust_port_id> chancopies;
413-
{
414-
scoped_lock with(weak_task_lock);
415-
chancopies = weak_task_chans;
416-
weak_task_chans.clear();
417-
}
418-
while (!chancopies.empty()) {
419-
rust_port_id chan = chancopies.back();
420-
chancopies.pop_back();
421-
KLOG_("Notifying weak task " PRIdPTR, chan);
422-
uintptr_t token = 0;
423-
send_to_port(chan, &token);
424-
}
425-
}
426-
427386
void
428387
rust_kernel::begin_shutdown() {
429388
{
@@ -439,7 +398,6 @@ rust_kernel::begin_shutdown() {
439398

440399
run_exit_functions();
441400
allow_scheduler_exit();
442-
end_weak_tasks();
443401
}
444402

445403
bool

src/rt/rust_kernel.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,9 @@ class rust_kernel {
119119

120120
// An atomically updated count of the live, 'non-weak' tasks
121121
uintptr_t non_weak_tasks;
122-
// Protects weak_task_chans
123-
lock_and_signal weak_task_lock;
124-
// A list of weak tasks that need to be told when to exit
125-
std::vector<rust_port_id> weak_task_chans;
126122

127123
rust_scheduler* get_scheduler_by_id_nolock(rust_sched_id id);
128124
void allow_scheduler_exit();
129-
void end_weak_tasks();
130125
void begin_shutdown();
131126

132127
lock_and_signal at_exit_lock;
@@ -180,8 +175,6 @@ class rust_kernel {
180175

181176
void register_task();
182177
void unregister_task();
183-
void weaken_task(rust_port_id chan);
184-
void unweaken_task(rust_port_id chan);
185178
void inc_weak_task_count();
186179
void dec_weak_task_count();
187180

src/rt/rustrt.def.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ rust_task_yield
6161
rust_task_is_unwinding
6262
rust_get_task
6363
rust_get_stack_segment
64-
rust_task_weaken
65-
rust_task_unweaken
6664
rust_log_str
6765
start_task
6866
vec_reserve_shared_actual

0 commit comments

Comments
 (0)