pub fn new(config: EventHandlerConfig) -> Self {
		let callbacks = Callbacks {
			on_read: None,
			on_accept: None,
			on_close: None,
			on_client_read: None,
		};
		let callbacks = Arc::new(RwLock::new(callbacks));

		let mut guarded_data = vec![];
		for _ in 0..config.thread_count + 1 {
			guarded_data.push(Arc::new(RwLock::new(GuardedData {
				nconns: vec![],
				write_queue: vec![],
				aconns: vec![],
				cconns: vec![],
				wakeup_tx: 0,
				wakeup_rx: 0,
				wakeup_scheduled: false,
				stop: false,
				callback_state: Arc::new(RwLock::new(State::Init)),
			})));
		}

		let global_lock = Arc::new(RwLock::new(true));

		let tls_server_config = if config.tls_config.is_some() {
			let tls_config = config.tls_config.as_ref().unwrap();
			match ServerConfig::builder()
				.with_safe_defaults()
				.with_no_client_auth()
				.with_single_cert(
					load_certs(&tls_config.certificates_file),
					load_private_key(&tls_config.private_key_file),
				) {
				Ok(tls_server_config) => Some(tls_server_config),
				Err(e) => {
					panic!("Error loading tls configurations: {}", e.to_string());
				}
			}
		} else {
			None
		};

		EventHandler {
			config,
			guarded_data,
			callbacks,
			global_lock,
			on_panic: None,
			tls_server_config,
			_pipe_listener: vec![],
			_pipe_stream: vec![],
		}
	}
/// Create a new instance of the [`EventHandler`]. Note that all callbacks must be registered
/// and [`EventHandler::start`] must be called before handleing events. See the example in the
/// [`EventHandler`] section of the documentation for a full details.
Create a new instance of the [`EventHandler`]. Note that all callbacks must be registered
and [`EventHandler::start`] must be called before handleing events. See the example in the
[`EventHandler`] section of the documentation for a full details.
Create a new instance of the [ ` EventHandler ` ] . Note that all callbacks must be registered and [ ` EventHandler :: start ` ] must be called before handleing events . See the example in the [ ` EventHandler ` ] section of the documentation for a full details .
pub fn new(config: EventHandlerConfig) -> Self {
		let callbacks = Callbacks {
			on_read: None,
			on_accept: None,
			on_close: None,
			on_client_read: None,
		};
		let callbacks = Arc::new(RwLock::new(callbacks));
		let mut guarded_data = vec![];
		for _ in 0..config.thread_count + 1 {
			guarded_data.push(Arc::new(RwLock::new(GuardedData {
				nconns: vec![],
				write_queue: vec![],
				aconns: vec![],
				cconns: vec![],
				wakeup_tx: 0,
				wakeup_rx: 0,
				wakeup_scheduled: false,
				stop: false,
				callback_state: Arc::new(RwLock::new(State::Init)),
			})));
		}
		let global_lock = Arc::new(RwLock::new(true));
		let tls_server_config = if config.tls_config.is_some() {
			let tls_config = config.tls_config.as_ref().unwrap();
			match ServerConfig::builder()
				.with_safe_defaults()
				.with_no_client_auth()
				.with_single_cert(
					load_certs(&tls_config.certificates_file),
					load_private_key(&tls_config.private_key_file),
				) {
				Ok(tls_server_config) => Some(tls_server_config),
				Err(e) => {
					panic!("Error loading tls configurations: {}", e.to_string());
				}
			}
		} else {
			None
		};
		EventHandler {
			config,
			guarded_data,
			callbacks,
			global_lock,
			on_panic: None,
			tls_server_config,
			_pipe_listener: vec![],
			_pipe_stream: vec![],
		}
	}
pub fn new ( config : EventHandlerConfig ) -> Self { let callbacks = Callbacks { on_read : None , on_accept : None , on_close : None , on_client_read : None , } ; let callbacks = Arc :: new ( RwLock :: new ( callbacks ) ) ; let mut guarded_data = vec ! [ ] ; for _ in 0 .. config . thread_count + 1 { guarded_data . push ( Arc :: new ( RwLock :: new ( GuardedData { nconns : vec ! [ ] , write_queue : vec ! [ ] , aconns : vec ! [ ] , cconns : vec ! [ ] , wakeup_tx : 0 , wakeup_rx : 0 , wakeup_scheduled : false , stop : false , callback_state : Arc :: new ( RwLock :: new ( State :: Init ) ) , } ) ) ) ; } let global_lock = Arc :: new ( RwLock :: new ( true ) ) ; let tls_server_config = if config . tls_config . is_some ( ) { let tls_config = config . tls_config . as_ref ( ) . unwrap ( ) ; match ServerConfig :: builder ( ) . with_safe_defaults ( ) . with_no_client_auth ( ) . with_single_cert ( load_certs ( & tls_config . certificates_file ) , load_private_key ( & tls_config . private_key_file ) , ) { Ok ( tls_server_config ) => Some ( tls_server_config ) , Err ( e ) => { panic ! ( " " e to_string ( ) ) ; } } } else { None } ; EventHandler { config , guarded_data , callbacks , global_lock , on_panic : None , tls_server_config , _pipe_listener : vec ! [ ] , _pipe_stream : vec ! [ ] , } }
Create a new instance of the [`EventHandler`].
Create a new instance of the [ ` EventHandler ` ] .
config
EventHandlerConfig
config
EventHandlerConfig