Skip to content

Commit cd8fb03

Browse files
committed
---
yaml --- r: 14653 b: refs/heads/try c: e08f46d h: refs/heads/master i: 14651: 25be79d v: v3
1 parent 44a0738 commit cd8fb03

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 77295c56c5b7edec061cbcd374ef584171088cbc
5+
refs/heads/try: e08f46db68b43334e5932ac5eac308ce74f0771e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rt/rust_builtin.cpp

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -544,29 +544,7 @@ rust_task_yield(rust_task *task, bool *killed) {
544544

545545
extern "C" CDECL void
546546
port_recv(uintptr_t *dptr, rust_port *port, uintptr_t *yield) {
547-
*yield = false;
548-
rust_task *task = rust_task_thread::get_task();
549-
{
550-
scoped_lock with(port->lock);
551-
552-
LOG(task, comm, "port: 0x%" PRIxPTR ", dptr: 0x%" PRIxPTR
553-
", size: 0x%" PRIxPTR,
554-
(uintptr_t) port, (uintptr_t) dptr, port->unit_sz);
555-
556-
if (port->receive(dptr)) {
557-
return;
558-
}
559-
560-
// No data was buffered on any incoming channel, so block this task on
561-
// the port. Remember the rendezvous location so that any sender task
562-
// can write to it before waking up this task.
563-
564-
LOG(task, comm, "<=== waiting for rendezvous data ===");
565-
task->rendezvous_ptr = dptr;
566-
task->block(port, "waiting for rendezvous data");
567-
}
568-
*yield = true;
569-
return;
547+
port->receive(dptr, yield);
570548
}
571549

572550
extern "C" CDECL void

branches/try/src/rt/rust_port.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,32 @@ void rust_port::send(void *sptr) {
6363
}
6464
}
6565

66-
bool rust_port::receive(void *dptr) {
67-
I(task->thread, lock.lock_held_by_current_thread());
66+
void rust_port::receive(void *dptr, uintptr_t *yield) {
67+
I(task->thread, !lock.lock_held_by_current_thread());
68+
69+
LOG(task, comm, "port: 0x%" PRIxPTR ", dptr: 0x%" PRIxPTR
70+
", size: 0x%" PRIxPTR,
71+
(uintptr_t) this, (uintptr_t) dptr, unit_sz);
72+
73+
scoped_lock with(lock);
74+
75+
*yield = false;
76+
6877
if (buffer.is_empty() == false) {
6978
buffer.dequeue(dptr);
7079
LOG(task, comm, "<=== read data ===");
71-
return true;
80+
return;
7281
}
73-
return false;
82+
83+
// No data was buffered on any incoming channel, so block this task on
84+
// the port. Remember the rendezvous location so that any sender task
85+
// can write to it before waking up this task.
86+
87+
LOG(task, comm, "<=== waiting for rendezvous data ===");
88+
task->rendezvous_ptr = (uintptr_t*) dptr;
89+
task->block(this, "waiting for rendezvous data");
90+
91+
*yield = true;
7492
}
7593

7694
size_t rust_port::size() {

branches/try/src/rt/rust_port.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class rust_port : public kernel_owned<rust_port>, public rust_cond {
2020
~rust_port();
2121
void log_state();
2222
void send(void *sptr);
23-
bool receive(void *dptr);
23+
void receive(void *dptr, uintptr_t *yield);
2424
size_t size();
2525
void detach();
2626
};

0 commit comments

Comments
 (0)