-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This was already fixed by the time I read the issue, but more test cases are always good. Closes #2718
- Loading branch information
1 parent
e9f1928
commit 91b69ae
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
fn sender_terminate<T:send>(p: *packet<T>) { | ||
} | ||
|
||
class send_packet<T: send> { | ||
let mut p: option<*packet<T>>; | ||
new(p: *packet<T>) { self.p = some(p); } | ||
drop { | ||
if self.p != none { | ||
let mut p = none; | ||
p <-> self.p; | ||
sender_terminate(option::unwrap(p)) | ||
} | ||
} | ||
fn unwrap() -> *packet<T> { | ||
let mut p = none; | ||
p <-> self.p; | ||
option::unwrap(p) | ||
} | ||
} | ||
|
||
enum state { | ||
empty, | ||
full, | ||
blocked, | ||
terminated | ||
} | ||
|
||
type packet<T: send> = { | ||
mut state: state, | ||
mut blocked_task: option<task::task>, | ||
mut payload: option<T> | ||
}; | ||
|
||
fn main() { | ||
let _s: send_packet<int> = send_packet(ptr::addr_of({mut state: empty, | ||
mut blocked_task: none, | ||
mut payload: some(42)})); | ||
} |