Skip to content

Commit 314e625

Browse files
committed
---
yaml --- r: 37293 b: refs/heads/try c: 6c4ad31 h: refs/heads/master i: 37291: 65262f2 v: v3
1 parent 649cc4c commit 314e625

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
5-
refs/heads/try: 34aabe5051c1d9666ac673d9da2e8413a694a169
5+
refs/heads/try: 6c4ad31f764aa8ebec3873ce68770b4173b0b97d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/src/libcore/condition.rs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
// helper for transmutation, shown below.
22
type RustClosure = (int,int);
33

4-
struct Condition {
5-
key: task::local_data::LocalDataKey<Handler>
4+
struct Condition<T, U:Copy> {
5+
key: task::local_data::LocalDataKey<Handler<T,U>>
66
}
77

8-
struct Handler {
8+
struct Handler<T, U:Copy> {
99
handle: RustClosure,
10-
prev: Option<@Handler>
10+
prev: Option<@Handler<T, U>>
1111
}
1212

1313

14-
struct ProtectBlock {
15-
cond: &Condition,
14+
struct ProtectBlock<T, U:Copy> {
15+
cond: &Condition<T, U>,
1616
inner: RustClosure
1717
}
1818

19-
struct PopHandler {
20-
cond: &Condition,
19+
struct PopHandler<T, U:Copy> {
20+
cond: &Condition<T,U>,
2121
drop {
2222
unsafe {
2323
debug!("PopHandler: popping handler from TLS");
@@ -35,9 +35,9 @@ struct PopHandler {
3535
}
3636
}
3737

38-
struct HandleBlock {
39-
pb: &ProtectBlock,
40-
handler: @Handler,
38+
struct HandleBlock<T, U:Copy> {
39+
pb: &ProtectBlock<T,U>,
40+
handler: @Handler<T,U>,
4141
drop {
4242
unsafe {
4343
debug!("HandleBlock: pushing handler to TLS");
@@ -54,8 +54,8 @@ struct HandleBlock {
5454
}
5555
}
5656

57-
impl ProtectBlock {
58-
fn handle<T, U: Copy>(&self, h: &self/fn(&T) ->U) -> HandleBlock/&self {
57+
impl<T, U: Copy> ProtectBlock<T,U> {
58+
fn handle(&self, h: &self/fn(&T) ->U) -> HandleBlock/&self<T,U> {
5959
unsafe {
6060
debug!("ProtectBlock.handle: setting up handler block");
6161
let p : *RustClosure = ::cast::transmute(&h);
@@ -67,9 +67,9 @@ impl ProtectBlock {
6767
}
6868

6969

70-
impl Condition {
70+
impl<T, U: Copy> Condition<T,U> {
7171

72-
fn protect(&self, inner: &self/fn()) -> ProtectBlock/&self {
72+
fn protect(&self, inner: &self/fn()) -> ProtectBlock/&self<T,U> {
7373
unsafe {
7474
// transmutation to avoid copying non-copyable, should
7575
// be fixable by tracking closure pointees in regionck.
@@ -80,7 +80,7 @@ impl Condition {
8080
}
8181
}
8282

83-
fn raise<T, U: Copy>(t:&T) -> U {
83+
fn raise(t:&T) -> U {
8484
unsafe {
8585
match task::local_data::local_data_get(self.key) {
8686
None => {
@@ -100,15 +100,13 @@ impl Condition {
100100

101101

102102
#[cfg(test)]
103-
fn happiness_key(_x: @Handler) { }
104-
105-
#[cfg(test)]
106-
fn sadness_key(_x: @Handler) { }
103+
fn sadness_key(_x: @Handler<int,int>) { }
107104

108105
#[cfg(test)]
109106
fn trouble(i: int) {
110107
// Condition should work as a const, just limitations in consts.
111-
let sadness_condition : Condition = Condition { key: sadness_key };
108+
let sadness_condition : Condition<int,int> =
109+
Condition { key: sadness_key };
112110
debug!("trouble: raising conition");
113111
let j = sadness_condition.raise(&i);
114112
debug!("trouble: handler recovered with %d", j);
@@ -117,7 +115,8 @@ fn trouble(i: int) {
117115
#[test]
118116
fn test1() {
119117

120-
let sadness_condition : Condition = Condition { key: sadness_key };
118+
let sadness_condition : Condition<int,int> =
119+
Condition { key: sadness_key };
121120

122121
let mut i = 10;
123122

@@ -138,7 +137,8 @@ fn test1() {
138137
}
139138
#[cfg(test)]
140139
fn nested_test_inner() {
141-
let sadness_condition : Condition = Condition { key: sadness_key };
140+
let sadness_condition : Condition<int,int> =
141+
Condition { key: sadness_key };
142142

143143
let mut inner_trapped = false;
144144

@@ -159,7 +159,8 @@ fn nested_test_inner() {
159159
#[test]
160160
fn nested_test_outer() {
161161

162-
let sadness_condition : Condition = Condition { key: sadness_key };
162+
let sadness_condition : Condition<int,int> =
163+
Condition { key: sadness_key };
163164

164165
let mut outer_trapped = false;
165166

0 commit comments

Comments
 (0)