fn start_housekeeping(&self) {
        // Spawn thread which schedules and runs housekeeping tasks
        let clone = self.clone();

        thread::spawn(move || {
            // Convert number to milliseconds
            let milliseconds = |milliseconds| Duration::from_millis(milliseconds);
            let daily = milliseconds(24 * 60 * 60 * 1_000);
            let hourly = milliseconds(60 * 60 * 1_000);
            let five_minutes = milliseconds(5 * 60 * 1_000);

            // Create channels
            let region_update = channel::tick(daily);
            let blacklist_reset = channel::tick(daily);
            let structure_update = channel::tick(hourly);
            let save_blacklist = channel::tick(five_minutes);

            loop {
                select! {
                    recv(region_update) -> _message => {
                        let clone = clone.clone();
                        thread::spawn(move || {
                            match clone.load_regions() {
                                Ok(_) => {}
                                Err(e) => {
                                    warn!("Loading regions from ESI failed: {}", e)
                                }
                            }
                        });
                    },
                    recv(blacklist_reset) -> _message => {
                        let clone = clone.clone();
                        thread::spawn(move || {
                            clone.clear_blacklist();
                        });
                    },
                    recv(structure_update) -> _message => {
                        let clone = clone.clone();
                        thread::spawn(move || {
                            match clone.load_structures() {
                                Ok(_) => {}
                                Err(e) => {
                                    warn!("Loading structures from 3rd party API failed: {}", e)
                                }
                            }
                        });
                    },
                    recv(save_blacklist) -> _message => {
                        let clone = clone.clone();
                        thread::spawn(move || {
                            match clone.persist_blacklist() {
                                Ok(_) => {}
                                Err(e) => {
                                    warn!("Could not save structure blacklist to disk: {}", e)
                                }
                            }
                        });
                    },
                }
            }
        });
    }
/// Maintain local state in regular intervals
Maintain local state in regular intervals
Maintain local state in regular intervals
fn start_housekeeping(&self) {
        // Spawn thread which schedules and runs housekeeping tasks
        let clone = self.clone();
        thread::spawn(move || {
            // Convert number to milliseconds
            let milliseconds = |milliseconds| Duration::from_millis(milliseconds);
            let daily = milliseconds(24 * 60 * 60 * 1_000);
            let hourly = milliseconds(60 * 60 * 1_000);
            let five_minutes = milliseconds(5 * 60 * 1_000);
            // Create channels
            let region_update = channel::tick(daily);
            let blacklist_reset = channel::tick(daily);
            let structure_update = channel::tick(hourly);
            let save_blacklist = channel::tick(five_minutes);
            loop {
                select! {
                    recv(region_update) -> _message => {
                        let clone = clone.clone();
                        thread::spawn(move || {
                            match clone.load_regions() {
                                Ok(_) => {}
                                Err(e) => {
                                    warn!("Loading regions from ESI failed: {}", e)
                                }
                            }
                        });
                    },
                    recv(blacklist_reset) -> _message => {
                        let clone = clone.clone();
                        thread::spawn(move || {
                            clone.clear_blacklist();
                        });
                    },
                    recv(structure_update) -> _message => {
                        let clone = clone.clone();
                        thread::spawn(move || {
                            match clone.load_structures() {
                                Ok(_) => {}
                                Err(e) => {
                                    warn!("Loading structures from 3rd party API failed: {}", e)
                                }
                            }
                        });
                    },
                    recv(save_blacklist) -> _message => {
                        let clone = clone.clone();
                        thread::spawn(move || {
                            match clone.persist_blacklist() {
                                Ok(_) => {}
                                Err(e) => {
                                    warn!("Could not save structure blacklist to disk: {}", e)
                                }
                            }
                        });
                    },
                }
            }
        });
    }
fn start_housekeeping ( & self ) { // Spawn thread which schedules and runs housekeeping tasks let clone = self . clone ( ) ; thread :: spawn ( move | | { // Convert number to milliseconds let milliseconds = | milliseconds | Duration :: from_millis ( milliseconds ) ; let daily = milliseconds ( 24 * 60 * 60 * 1_000 ) ; let hourly = milliseconds ( 60 * 60 * 1_000 ) ; let five_minutes = milliseconds ( 5 * 60 * 1_000 ) ; // Create channels let region_update = channel :: tick ( daily ) ; let blacklist_reset = channel :: tick ( daily ) ; let structure_update = channel :: tick ( hourly ) ; let save_blacklist = channel :: tick ( five_minutes ) ; loop { select ! { recv ( region_update ) _message { let clone clone clone ( ) thread spawn ( move { match clone load_regions ( ) { Ok ( ) { } Err ( e ) { warn ( " " e ) } } } ) } recv ( blacklist_reset ) _message { let clone clone clone ( ) thread spawn ( move { clone clear_blacklist ( ) } ) } recv ( structure_update ) _message { let clone clone clone ( ) thread spawn ( move { match clone load_structures ( ) { Ok ( ) { } Err ( e ) { warn ( " " e ) } } } ) } recv ( save_blacklist ) _message { let clone clone clone ( ) thread spawn ( move { match clone persist_blacklist ( ) { Ok ( ) { } Err ( e ) { warn ( " " e ) } } } ) } } } } ) ; }
Maintain local state in regular intervals
Maintain local state in regular intervals
&self
&self