@@ -230,7 +230,7 @@ use clone::Clone;
230
230
use container:: Container ;
231
231
use int;
232
232
use iter:: Iterator ;
233
- use kinds:: Send ;
233
+ use kinds:: { Send , NotFreeze } ;
234
234
use ops:: Drop ;
235
235
use option:: { Option , Some , None } ;
236
236
use result:: { Ok , Err } ;
@@ -297,9 +297,9 @@ impl<T: Send> Consumer<T>{
297
297
298
298
/// The receiving-half of Rust's channel type. This half can only be owned by
299
299
/// one task
300
- #[ no_freeze] // can't share ports in an arc
301
300
pub struct Port < T > {
302
301
priv queue : Consumer < T > ,
302
+ priv nf: NotFreeze ,
303
303
}
304
304
305
305
/// An iterator over messages received on a port, this iterator will block
@@ -311,17 +311,16 @@ pub struct Messages<'a, T> {
311
311
312
312
/// The sending-half of Rust's channel type. This half can only be owned by one
313
313
/// task
314
- #[ no_freeze] // can't share chans in an arc
315
314
pub struct Chan < T > {
316
315
priv queue : spsc:: Producer < T , Packet > ,
316
+ priv nf: NotFreeze ,
317
317
}
318
318
319
319
/// The sending-half of Rust's channel type. This half can be shared among many
320
320
/// tasks by creating copies of itself through the `clone` method.
321
- #[ no_freeze] // technically this implementation is shareable, but it shouldn't
322
- // be required to be shareable in an arc
323
321
pub struct SharedChan < T > {
324
322
priv queue : mpsc:: Producer < T , Packet > ,
323
+ priv nf: NotFreeze ,
325
324
}
326
325
327
326
/// This enumeration is the list of the possible reasons that try_recv could not
@@ -545,7 +544,7 @@ impl<T: Send> Chan<T> {
545
544
// maximum buffer size
546
545
let ( c, p) = spsc:: queue ( 128 , Packet :: new ( ) ) ;
547
546
let c = SPSC ( c) ;
548
- ( Port { queue : c } , Chan { queue : p } )
547
+ ( Port { queue : c, nf : NotFreeze } , Chan { queue : p, nf : NotFreeze } )
549
548
}
550
549
551
550
/// Sends a value along this channel to be received by the corresponding
@@ -640,7 +639,7 @@ impl<T: Send> SharedChan<T> {
640
639
pub fn new ( ) -> ( Port < T > , SharedChan < T > ) {
641
640
let ( c, p) = mpsc:: queue ( Packet :: new ( ) ) ;
642
641
let c = MPSC ( c) ;
643
- ( Port { queue : c } , SharedChan { queue : p } )
642
+ ( Port { queue : c, nf : NotFreeze } , SharedChan { queue : p, nf : NotFreeze } )
644
643
}
645
644
646
645
/// Equivalent method to `send` on the `Chan` type (using the same
@@ -706,7 +705,7 @@ impl<T: Send> SharedChan<T> {
706
705
impl < T : Send > Clone for SharedChan < T > {
707
706
fn clone ( & self ) -> SharedChan < T > {
708
707
unsafe { ( * self . queue . packet ( ) ) . channels . fetch_add ( 1 , SeqCst ) ; }
709
- SharedChan { queue : self . queue . clone ( ) }
708
+ SharedChan { queue : self . queue . clone ( ) , nf : NotFreeze }
710
709
}
711
710
}
712
711
0 commit comments