File tree 3 files changed +29
-15
lines changed 3 files changed +29
-15
lines changed Original file line number Diff line number Diff line change @@ -74,14 +74,14 @@ jobs:
74
74
- name : Docs
75
75
run : cargo doc --features docs
76
76
77
- clippy_check :
78
- name : Clippy check
79
- runs-on : ubuntu-latest
80
- steps :
81
- - uses : actions/checkout@v1
82
- - name : Install rust
83
- run : rustup update beta && rustup default beta
84
- - name : Install clippy
85
- run : rustup component add clippy
86
- - name : clippy
87
- run : cargo clippy --all --features unstable
77
+ # clippy_check:
78
+ # name: Clippy check
79
+ # runs-on: ubuntu-latest
80
+ # steps:
81
+ # - uses: actions/checkout@v1
82
+ # - name: Install rust
83
+ # run: rustup update beta && rustup default beta
84
+ # - name: Install clippy
85
+ # run: rustup component add clippy
86
+ # - name: clippy
87
+ # run: cargo clippy --all --features unstable
Original file line number Diff line number Diff line change @@ -677,6 +677,14 @@ impl<T> Channel<T> {
677
677
let mut tail = self . tail . load ( Ordering :: Relaxed ) ;
678
678
679
679
loop {
680
+ // Extract mark bit from the tail and unset it.
681
+ //
682
+ // If the mark bit was set (which means all receivers have been dropped), we will still
683
+ // send the message into the channel if there is enough capacity. The message will get
684
+ // dropped when the channel is dropped (which means when all senders are also dropped).
685
+ let mark_bit = tail & self . mark_bit ;
686
+ tail ^= mark_bit;
687
+
680
688
// Deconstruct the tail.
681
689
let index = tail & ( self . mark_bit - 1 ) ;
682
690
let lap = tail & !( self . one_lap - 1 ) ;
@@ -699,8 +707,8 @@ impl<T> Channel<T> {
699
707
700
708
// Try moving the tail.
701
709
match self . tail . compare_exchange_weak (
702
- tail,
703
- new_tail,
710
+ tail | mark_bit ,
711
+ new_tail | mark_bit ,
704
712
Ordering :: SeqCst ,
705
713
Ordering :: Relaxed ,
706
714
) {
@@ -732,7 +740,7 @@ impl<T> Channel<T> {
732
740
// ...then the channel is full.
733
741
734
742
// Check if the channel is disconnected.
735
- if tail & self . mark_bit != 0 {
743
+ if mark_bit != 0 {
736
744
return Err ( TrySendError :: Disconnected ( msg) ) ;
737
745
} else {
738
746
return Err ( TrySendError :: Full ( msg) ) ;
Original file line number Diff line number Diff line change @@ -25,7 +25,13 @@ fn smoke() {
25
25
26
26
drop ( s) ;
27
27
assert_eq ! ( r. recv( ) . await , None ) ;
28
- } )
28
+ } ) ;
29
+
30
+ task:: block_on ( async {
31
+ let ( s, r) = channel ( 10 ) ;
32
+ drop ( r) ;
33
+ s. send ( 1 ) . await ;
34
+ } ) ;
29
35
}
30
36
31
37
#[ test]
You can’t perform that action at this time.
0 commit comments