File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -432,6 +432,21 @@ impl Context {
432
432
}
433
433
}
434
434
435
+ /// Get the size of the ØMQ thread pool to handle I/O operations.
436
+ pub fn get_io_threads ( & self ) -> Result < i32 > {
437
+ let rc =
438
+ zmq_try ! ( unsafe { zmq_sys:: zmq_ctx_get( self . raw. ctx, zmq_sys:: ZMQ_IO_THREADS as _) } ) ;
439
+ Ok ( rc as i32 )
440
+ }
441
+
442
+ /// Set the size of the ØMQ thread pool to handle I/O operations.
443
+ pub fn set_io_threads ( & self , value : i32 ) -> Result < ( ) > {
444
+ zmq_try ! ( unsafe {
445
+ zmq_sys:: zmq_ctx_set( self . raw. ctx, zmq_sys:: ZMQ_IO_THREADS as _, value as i32 )
446
+ } ) ;
447
+ Ok ( ( ) )
448
+ }
449
+
435
450
/// Create a new socket.
436
451
///
437
452
/// 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