gio/
threaded_socket_service.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::{prelude::*, translate::*};
4
5use crate::{SocketService, ThreadedSocketService};
6
7impl ThreadedSocketService {
8    /// Creates a new #GThreadedSocketService with no listeners. Listeners
9    /// must be added with one of the #GSocketListener "add" methods.
10    /// ## `max_threads`
11    /// the maximal number of threads to execute concurrently
12    ///   handling incoming clients, -1 means no limit
13    ///
14    /// # Returns
15    ///
16    /// a new #GSocketService.
17    #[doc(alias = "g_threaded_socket_service_new")]
18    pub fn new(max_threads: Option<u32>) -> ThreadedSocketService {
19        let max_threads = max_threads.map(|x| x as i32).unwrap_or(-1);
20        unsafe {
21            SocketService::from_glib_full(crate::ffi::g_threaded_socket_service_new(max_threads))
22                .unsafe_cast()
23        }
24    }
25}