File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -428,6 +428,21 @@ impl Context {
428428 }
429429 }
430430
431+ /// Get the size of the ØMQ thread pool to handle I/O operations.
432+ pub fn get_io_threads ( & self ) -> Result < i32 > {
433+ let rc =
434+ zmq_try ! ( unsafe { zmq_sys:: zmq_ctx_get( self . raw. ctx, zmq_sys:: ZMQ_IO_THREADS as _) } ) ;
435+ Ok ( rc as i32 )
436+ }
437+
438+ /// Set the size of the ØMQ thread pool to handle I/O operations.
439+ pub fn set_io_threads ( & self , value : i32 ) -> Result < ( ) > {
440+ zmq_try ! ( unsafe {
441+ zmq_sys:: zmq_ctx_set( self . raw. ctx, zmq_sys:: ZMQ_IO_THREADS as _, value as i32 )
442+ } ) ;
443+ Ok ( ( ) )
444+ }
445+
431446 /// Create a new socket.
432447 ///
433448 /// Note that the returned socket keeps a an `Arc` reference to
Original file line number Diff line number Diff line change 1+ #[ test]
2+ fn context_io_threads ( ) {
3+ let ctx = zmq:: Context :: new ( ) ;
4+
5+ assert_eq ! ( ctx. get_io_threads( ) . unwrap( ) , zmq_sys:: ZMQ_IO_THREADS_DFLT as i32 ) ;
6+
7+ ctx. set_io_threads ( 0 ) . unwrap ( ) ;
8+ assert_eq ! ( ctx. get_io_threads( ) . unwrap( ) , 0 ) ;
9+
10+ ctx. set_io_threads ( 7 ) . unwrap ( ) ;
11+ assert_eq ! ( ctx. get_io_threads( ) . unwrap( ) , 7 ) ;
12+
13+ assert ! ( ctx. set_io_threads( -1 ) . is_err( ) ) ;
14+ }
You can’t perform that action at this time.
0 commit comments