Skip to content

Commit 86947e4

Browse files
committed
More documentation on pipes, and moving assert in runtime.
1 parent d8e9724 commit 86947e4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/libcore/pipes.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@ buffer that is carried along in the endpoint data structures.
4141
4242
FIXME (#3072) - This is still incomplete
4343
44+
45+
46+
## Invariants
47+
48+
This section attempts to document the invariants that must hold to
49+
avoid races. These primarily deal with the state and blocked_task
50+
fields on packet_headers.
51+
52+
1. If the sender reads a some(task) out of blocked_task, then the task
53+
that is pointed there will remain live for any events that the sender
54+
might signal.
55+
56+
2. The sender may only read the blocked_task field if it first ensures
57+
that the packet's state field is blocked.
58+
4459
*/
4560

4661
import unsafe::{forget, reinterpret_cast, transmute};

src/rt/rust_task.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,11 +678,11 @@ MUST_CHECK bool rust_task::wait_event(void **result) {
678678

679679
void
680680
rust_task::signal_event(void *event) {
681-
scoped_lock with(lifecycle_lock);
682-
683681
assert(task_state_blocked == state ||
684682
task_state_running == state);
685683

684+
scoped_lock with(lifecycle_lock);
685+
686686
this->event = event;
687687
event_reject = true;
688688
if(task_state_blocked == state) {

0 commit comments

Comments
 (0)