Cleanup ActorRegistry::create_shareable.

This commit is contained in:
Ms2ger 2015-08-19 14:26:19 +02:00
parent 0234bbe444
commit f62fbbaed8

View file

@ -110,16 +110,18 @@ impl ActorRegistry {
} }
/// Creating shareable registry /// Creating shareable registry
pub fn create_shareable(self) -> Arc<Mutex<ActorRegistry>>{ pub fn create_shareable(self) -> Arc<Mutex<ActorRegistry>> {
if self.shareable.is_some() { if let Some(shareable) = self.shareable {
return self.shareable.unwrap(); return shareable;
} }
let shareable = Arc::new(Mutex::new(self)); let shareable = Arc::new(Mutex::new(self));
let mut lock = shareable.lock(); {
let registry = lock.as_mut().unwrap(); let mut lock = shareable.lock();
registry.shareable = Some(shareable.clone()); let registry = lock.as_mut().unwrap();
shareable.clone() registry.shareable = Some(shareable.clone());
}
shareable
} }
/// Get shareable registry through threads /// Get shareable registry through threads