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