Skip to content

Commit fe12da0

Browse files
committed
De-mode comm::Chan
1 parent 777baeb commit fe12da0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+173
-173
lines changed

doc/rust.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,7 +2952,7 @@ An example of a `spawn` call:
29522952

29532953
~~~~
29542954
let po = comm::Port();
2955-
let ch = comm::Chan(po);
2955+
let ch = comm::Chan(&po);
29562956
29572957
do task::spawn {
29582958
// let task run, do other things
@@ -2974,7 +2974,7 @@ An example of a send:
29742974

29752975
~~~~
29762976
let po = comm::Port();
2977-
let ch = comm::Chan(po);
2977+
let ch = comm::Chan(&po);
29782978
comm::send(ch, ~"hello, world");
29792979
~~~~
29802980

@@ -2990,7 +2990,7 @@ An example of a *receive*:
29902990

29912991
~~~~~~~~
29922992
# let po = comm::Port();
2993-
# let ch = comm::Chan(po);
2993+
# let ch = comm::Chan(&po);
29942994
# comm::send(ch, ~"");
29952995
let s = comm::recv(po);
29962996
~~~~~~~~

src/libcore/comm.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ will once again be the preferred module for intertask communication.
3232
3333
*/
3434

35-
// NB: transitionary, de-mode-ing
36-
// tjc: re-forbid deprecated modes after snapshot
35+
// NB: transitionary, de-mode-ing.
36+
#[forbid(deprecated_mode)];
3737
#[forbid(deprecated_pattern)];
3838

3939
use either::Either;
@@ -74,7 +74,7 @@ pub fn Port<T: Send>() -> Port<T> {
7474

7575
impl<T: Send> Port<T> {
7676

77-
fn chan() -> Chan<T> { Chan(self) }
77+
fn chan() -> Chan<T> { Chan(&self) }
7878
fn send(v: T) { self.chan().send(move v) }
7979
fn recv() -> T { recv(self) }
8080
fn peek() -> bool { peek(self) }
@@ -166,7 +166,7 @@ fn as_raw_port<T: Send, U>(ch: comm::Chan<T>, f: fn(*rust_port) -> U) -> U {
166166
* Constructs a channel. The channel is bound to the port used to
167167
* construct it.
168168
*/
169-
pub fn Chan<T: Send>(&&p: Port<T>) -> Chan<T> {
169+
pub fn Chan<T: Send>(p: &Port<T>) -> Chan<T> {
170170
Chan_(rustrt::get_port_id((**p).po))
171171
}
172172

@@ -304,51 +304,51 @@ extern mod rusti {
304304

305305

306306
#[test]
307-
fn create_port_and_chan() { let p = Port::<int>(); Chan(p); }
307+
fn create_port_and_chan() { let p = Port::<int>(); Chan(&p); }
308308

309309
#[test]
310310
fn send_int() {
311311
let p = Port::<int>();
312-
let c = Chan(p);
312+
let c = Chan(&p);
313313
send(c, 22);
314314
}
315315

316316
#[test]
317317
fn send_recv_fn() {
318318
let p = Port::<int>();
319-
let c = Chan::<int>(p);
319+
let c = Chan::<int>(&p);
320320
send(c, 42);
321321
assert (recv(p) == 42);
322322
}
323323

324324
#[test]
325325
fn send_recv_fn_infer() {
326326
let p = Port();
327-
let c = Chan(p);
327+
let c = Chan(&p);
328328
send(c, 42);
329329
assert (recv(p) == 42);
330330
}
331331

332332
#[test]
333333
fn chan_chan_infer() {
334334
let p = Port(), p2 = Port::<int>();
335-
let c = Chan(p);
336-
send(c, Chan(p2));
335+
let c = Chan(&p);
336+
send(c, Chan(&p2));
337337
recv(p);
338338
}
339339

340340
#[test]
341341
fn chan_chan() {
342342
let p = Port::<Chan<int>>(), p2 = Port::<int>();
343-
let c = Chan(p);
344-
send(c, Chan(p2));
343+
let c = Chan(&p);
344+
send(c, Chan(&p2));
345345
recv(p);
346346
}
347347

348348
#[test]
349349
fn test_peek() {
350350
let po = Port();
351-
let ch = Chan(po);
351+
let ch = Chan(&po);
352352
assert !peek(po);
353353
send(ch, ());
354354
assert peek(po);
@@ -360,8 +360,8 @@ fn test_peek() {
360360
fn test_select2_available() {
361361
let po_a = Port();
362362
let po_b = Port();
363-
let ch_a = Chan(po_a);
364-
let ch_b = Chan(po_b);
363+
let ch_a = Chan(&po_a);
364+
let ch_b = Chan(&po_b);
365365

366366
send(ch_a, ~"a");
367367

@@ -376,8 +376,8 @@ fn test_select2_available() {
376376
fn test_select2_rendezvous() {
377377
let po_a = Port();
378378
let po_b = Port();
379-
let ch_a = Chan(po_a);
380-
let ch_b = Chan(po_b);
379+
let ch_a = Chan(&po_a);
380+
let ch_b = Chan(&po_b);
381381
382382
for iter::repeat(10) {
383383
do task::spawn {
@@ -400,8 +400,8 @@ fn test_select2_rendezvous() {
400400
fn test_select2_stress() {
401401
let po_a = Port();
402402
let po_b = Port();
403-
let ch_a = Chan(po_a);
404-
let ch_b = Chan(po_b);
403+
let ch_a = Chan(&po_a);
404+
let ch_b = Chan(&po_b);
405405
406406
let msgs = 100;
407407
let times = 4u;
@@ -436,7 +436,7 @@ fn test_select2_stress() {
436436
#[test]
437437
fn test_recv_chan() {
438438
let po = Port();
439-
let ch = Chan(po);
439+
let ch = Chan(&po);
440440
send(ch, ~"flower");
441441
assert recv_chan(ch) == ~"flower";
442442
}
@@ -445,7 +445,7 @@ fn test_recv_chan() {
445445
#[should_fail]
446446
#[ignore(cfg(windows))]
447447
fn test_recv_chan_dead() {
448-
let ch = Chan(Port());
448+
let ch = Chan(&Port());
449449
send(ch, ~"flower");
450450
recv_chan(ch);
451451
}
@@ -454,7 +454,7 @@ fn test_recv_chan_dead() {
454454
#[ignore(cfg(windows))]
455455
fn test_recv_chan_wrong_task() {
456456
let po = Port();
457-
let ch = Chan(po);
457+
let ch = Chan(&po);
458458
send(ch, ~"flower");
459459
assert result::is_err(&task::try(||
460460
recv_chan(ch)

src/libcore/option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,10 @@ impl<T: Eq> Option<T> : Eq {
326326
#[test]
327327
fn test_unwrap_ptr() {
328328
let x = ~0;
329-
let addr_x = ptr::p2::addr_of(&(*x));
329+
let addr_x = ptr::addr_of(&(*x));
330330
let opt = Some(x);
331331
let y = unwrap(opt);
332-
let addr_y = ptr::p2::addr_of(&(*y));
332+
let addr_y = ptr::addr_of(&(*y));
333333
assert addr_x == addr_y;
334334
}
335335

src/libcore/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ mod global_env {
132132
let env_ch = get_global_env_chan();
133133
let po = comm::Port();
134134
comm::send(env_ch, MsgGetEnv(str::from_slice(n),
135-
comm::Chan(po)));
135+
comm::Chan(&po)));
136136
comm::recv(po)
137137
}
138138

@@ -141,14 +141,14 @@ mod global_env {
141141
let po = comm::Port();
142142
comm::send(env_ch, MsgSetEnv(str::from_slice(n),
143143
str::from_slice(v),
144-
comm::Chan(po)));
144+
comm::Chan(&po)));
145145
comm::recv(po)
146146
}
147147

148148
pub fn env() -> ~[(~str,~str)] {
149149
let env_ch = get_global_env_chan();
150150
let po = comm::Port();
151-
comm::send(env_ch, MsgEnv(comm::Chan(po)));
151+
comm::send(env_ch, MsgEnv(comm::Chan(&po)));
152152
comm::recv(po)
153153
}
154154

src/libcore/private.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub unsafe fn chan_from_global_ptr<T: Send>(
6363
let (setup_po, setup_ch) = do task_fn().spawn_conversation
6464
|move f, setup_po, setup_ch| {
6565
let po = comm::Port::<T>();
66-
let ch = comm::Chan(po);
66+
let ch = comm::Chan(&po);
6767
comm::send(setup_ch, ch);
6868
6969
// Wait to hear if we are the official instance of
@@ -109,7 +109,7 @@ pub fn test_from_global_chan1() {
109109

110110
// The global channel
111111
let globchan = 0;
112-
let globchanp = ptr::p2::addr_of(&globchan);
112+
let globchanp = ptr::addr_of(&globchan);
113113

114114
// Create the global channel, attached to a new task
115115
let ch = unsafe {
@@ -122,7 +122,7 @@ pub fn test_from_global_chan1() {
122122
};
123123
// Talk to it
124124
let po = comm::Port();
125-
comm::send(ch, comm::Chan(po));
125+
comm::send(ch, comm::Chan(&po));
126126
assert comm::recv(po) == true;
127127

128128
// This one just reuses the previous channel
@@ -135,7 +135,7 @@ pub fn test_from_global_chan1() {
135135

136136
// Talk to the original global task
137137
let po = comm::Port();
138-
comm::send(ch, comm::Chan(po));
138+
comm::send(ch, comm::Chan(&po));
139139
assert comm::recv(po) == true;
140140
}
141141

@@ -145,10 +145,10 @@ pub fn test_from_global_chan2() {
145145
for iter::repeat(100) {
146146
// The global channel
147147
let globchan = 0;
148-
let globchanp = ptr::p2::addr_of(&globchan);
148+
let globchanp = ptr::addr_of(&globchan);
149149

150150
let resultpo = comm::Port();
151-
let resultch = comm::Chan(resultpo);
151+
let resultch = comm::Chan(&resultpo);
152152

153153
// Spawn a bunch of tasks that all want to compete to
154154
// create the global channel
@@ -165,7 +165,7 @@ pub fn test_from_global_chan2() {
165165
}
166166
};
167167
let po = comm::Port();
168-
comm::send(ch, comm::Chan(po));
168+
comm::send(ch, comm::Chan(&po));
169169
// We are The winner if our version of the
170170
// task was installed
171171
let winner = comm::recv(po);
@@ -203,7 +203,7 @@ pub fn test_from_global_chan2() {
203203
*/
204204
pub unsafe fn weaken_task(f: fn(comm::Port<()>)) {
205205
let po = comm::Port();
206-
let ch = comm::Chan(po);
206+
let ch = comm::Chan(&po);
207207
unsafe {
208208
rustrt::rust_task_weaken(cast::reinterpret_cast(&ch));
209209
}

src/libcore/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pub fn program_output(prog: &str, args: &[~str]) ->
296296
// or the other. FIXME (#2625): Surely there's a much more
297297
// clever way to do this.
298298
let p = comm::Port();
299-
let ch = comm::Chan(p);
299+
let ch = comm::Chan(&p);
300300
do task::spawn_sched(task::SingleThreaded) {
301301
let errput = readclose(pipe_err.in);
302302
comm::send(ch, (2, move errput));

0 commit comments

Comments
 (0)