Skip to content

Commit bb7cd28

Browse files
author
Eric Holk
committed
---
yaml --- r: 3709 b: refs/heads/master c: 4739953 h: refs/heads/master i: 3707: 63590ab v: v3
1 parent aacc6c4 commit bb7cd28

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 2d57b25f6b3803ec505ba4909302bebb2cad4afd
2+
refs/heads/master: 4739953b84b814de3b2b80f273f6292c33e33010

trunk/src/rt/circular_buffer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ circular_buffer::circular_buffer(rust_task *task, size_t unit_sz) :
2020
_buffer_sz, _unread, this);
2121

2222
A(sched, _buffer, "Failed to allocate buffer.");
23+
task->ref();
2324
}
2425

2526
circular_buffer::~circular_buffer() {
@@ -28,6 +29,7 @@ circular_buffer::~circular_buffer() {
2829
W(sched, _unread == 0,
2930
"freeing circular_buffer with %d unread bytes", _unread);
3031
task->free(_buffer);
32+
--task->ref_count;
3133
}
3234

3335
size_t

trunk/src/rt/rust_builtin.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,16 @@ task_yield(rust_task *task) {
393393
extern "C" CDECL void
394394
task_join(rust_task *task, rust_task *join_task) {
395395
// If the other task is already dying, we don't have to wait for it.
396+
join_task->lock.lock();
396397
if (join_task->dead() == false) {
397398
join_task->tasks_waiting_to_join.push(task);
398399
task->block(join_task, "joining local task");
400+
join_task->lock.unlock();
399401
task->yield(2);
400402
}
403+
else {
404+
join_task->lock.unlock();
405+
}
401406
}
402407

403408
/* Debug builtins for std.dbg. */

trunk/src/rt/rust_task.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,15 @@ void task_start_wrapper(spawn_args *a)
118118
a->f(&rval, task, a->a3, a->a4);
119119

120120
LOG(task, task, "task exited with value %d", rval);
121+
121122

122123
LOG(task, task, "task ref_count: %d", task->ref_count);
123124
A(task->sched, task->ref_count >= 0,
124125
"Task ref_count should not be negative on exit!");
125126
task->die();
127+
task->lock.lock();
126128
task->notify_tasks_waiting_to_join();
129+
task->lock.unlock();
127130

128131
task->yield(1);
129132
}

0 commit comments

Comments
 (0)