File tree Expand file tree Collapse file tree 6 files changed +20
-6
lines changed Expand file tree Collapse file tree 6 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ impl Drop for DealerSocket {
3131#[ async_trait]
3232impl Socket for DealerSocket {
3333 fn with_options ( options : SocketOptions ) -> Self {
34- let fair_queue = FairQueue :: new ( true ) ;
34+ let fair_queue = FairQueue :: new ( options . block_on_no_clients ) ;
3535 Self {
3636 backend : Arc :: new ( GenericSocketBackend :: with_options (
3737 Some ( fair_queue. inner ( ) ) ,
Original file line number Diff line number Diff line change @@ -169,16 +169,30 @@ pub enum SocketEvent {
169169 Disconnected ( PeerIdentity ) ,
170170}
171171
172- #[ derive( Default ) ]
172+ #[ derive( Debug , Clone ) ]
173173pub struct SocketOptions {
174174 pub ( crate ) peer_id : Option < PeerIdentity > ,
175+ pub ( crate ) block_on_no_clients : bool ,
176+ }
177+
178+ impl Default for SocketOptions {
179+ fn default ( ) -> Self {
180+ Self {
181+ peer_id : Default :: default ( ) ,
182+ block_on_no_clients : true ,
183+ }
184+ }
175185}
176186
177187impl SocketOptions {
178188 pub fn peer_identity ( & mut self , peer_id : PeerIdentity ) -> & mut Self {
179189 self . peer_id = Some ( peer_id) ;
180190 self
181191 }
192+ pub fn block_on_no_clients ( & mut self , block_on_no_clients : bool ) -> & mut Self {
193+ self . block_on_no_clients = block_on_no_clients;
194+ self
195+ }
182196}
183197
184198#[ async_trait]
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ pub struct PullSocket {
2525#[ async_trait]
2626impl Socket for PullSocket {
2727 fn with_options ( options : SocketOptions ) -> Self {
28- let fair_queue = FairQueue :: new ( true ) ;
28+ let fair_queue = FairQueue :: new ( options . block_on_no_clients ) ;
2929 Self {
3030 backend : Arc :: new ( GenericSocketBackend :: with_options (
3131 Some ( fair_queue. inner ( ) ) ,
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ impl Drop for RepSocket {
4343#[ async_trait]
4444impl Socket for RepSocket {
4545 fn with_options ( options : SocketOptions ) -> Self {
46- let fair_queue = FairQueue :: new ( true ) ;
46+ let fair_queue = FairQueue :: new ( options . block_on_no_clients ) ;
4747 Self {
4848 backend : Arc :: new ( RepSocketBackend {
4949 peers : DashMap :: new ( ) ,
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ impl Drop for RouterSocket {
3232#[ async_trait]
3333impl Socket for RouterSocket {
3434 fn with_options ( options : SocketOptions ) -> Self {
35- let fair_queue = FairQueue :: new ( true ) ;
35+ let fair_queue = FairQueue :: new ( options . block_on_no_clients ) ;
3636 Self {
3737 backend : Arc :: new ( GenericSocketBackend :: with_options (
3838 Some ( fair_queue. inner ( ) ) ,
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ impl SubSocket {
156156#[ async_trait]
157157impl Socket for SubSocket {
158158 fn with_options ( options : SocketOptions ) -> Self {
159- let fair_queue = FairQueue :: new ( true ) ;
159+ let fair_queue = FairQueue :: new ( options . block_on_no_clients ) ;
160160 Self {
161161 backend : Arc :: new ( SubSocketBackend :: with_options (
162162 Some ( fair_queue. inner ( ) ) ,
You can’t perform that action at this time.
0 commit comments