Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
write lock immediately after read lock in distributed runtime selector
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Dec 17, 2018
1 parent 9cc5814 commit 62d6b88
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions distributed-fly/src/runtime_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl RuntimeSelector for DistributedRuntimeSelector {

{
if !runtimes.read().unwrap().contains_key(&key) {
let mut writer = runtimes.write().unwrap();
let settings = {
use fly::settings::*;
let global_settings = &*GLOBAL_SETTINGS.read().unwrap();
Expand Down Expand Up @@ -75,9 +76,13 @@ impl RuntimeSelector for DistributedRuntimeSelector {
})),
}
};
let mut rt = Runtime::new(Some(rel.app_id.to_string()), Some(rel.version.to_string()), &settings);
let mut rt = Runtime::new(
Some(rel.app_id.to_string()),
Some(rel.version.to_string()),
&settings,
);
let merged_conf = rel.clone().parsed_config().unwrap();
rt.eval(
rt.eval(
"<app config>",
&format!("window.app = {{ config: {} }};", merged_conf),
);
Expand All @@ -95,10 +100,7 @@ impl RuntimeSelector for DistributedRuntimeSelector {
// runtimes.write().unwrap().remove(&key2);
Ok(())
}));
{
debug!("writing runtime in hashmap");
runtimes.write().unwrap().insert(key.clone(), rt);
}
writer.insert(key.clone(), rt);
}
}

Expand Down

0 comments on commit 62d6b88

Please sign in to comment.