}
}
-fn config_read() -> MappedRwLockReadGuard<'static, WholeServerConfig> {
- {
- let g = GLOBAL.config.read();
- let g = RwLockReadGuard::try_map(g, |g| g.as_ref());
- if let Ok(g) = g { return g }
- }
- {
- let mut g = GLOBAL.config.write();
- g.get_or_insert_with(default);
- let g = RwLockWriteGuard::downgrade(g);
- RwLockReadGuard::try_map(g, |g| g.as_ref()).unwrap()
- }
-}
-
pub fn config() -> Arc<ServerConfig> {
- config_read().server.clone()
+ GLOBAL.config.read().server.clone()
}
pub fn log_config() -> LogSpecification {
- config_read().log.clone()
+ GLOBAL.config.read().log.clone()
}
fn set_config(whole: WholeServerConfig) {
- *GLOBAL.config.write() = Some(whole);
+ *GLOBAL.config.write() = whole;
}
impl ServerConfig {
// <- InstanceContainer ->
// inner locks which the game needs:
dirty: Mutex<VecDeque<InstanceRef>>,
- pub config: RwLock<Option<WholeServerConfig>>,
+ pub config: RwLock<WholeServerConfig>,
// fast global lookups
players: RwLock<TokenTable<PlayerId>>,
pub use ordered_float::OrderedFloat;
pub use parking_lot::{Condvar, Mutex, MutexGuard};
pub use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
-pub use parking_lot::{MappedRwLockReadGuard};
pub use percent_encoding::percent_decode_str;
pub use percent_encoding::utf8_percent_encode;
pub use percent_encoding::NON_ALPHANUMERIC;