-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1244 from hannobraun/host
Don't block window thread when compiling model
- Loading branch information
Showing
13 changed files
with
594 additions
and
544 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::Parameters; | ||
|
||
pub struct Host<'a> { | ||
args: &'a Parameters, | ||
model: Option<Box<dyn fj::models::Model>>, | ||
} | ||
|
||
impl<'a> Host<'a> { | ||
pub fn new(parameters: &'a Parameters) -> Self { | ||
Self { | ||
args: parameters, | ||
model: None, | ||
} | ||
} | ||
|
||
pub fn take_model(&mut self) -> Option<Box<dyn fj::models::Model>> { | ||
self.model.take() | ||
} | ||
} | ||
|
||
impl<'a> fj::models::Host for Host<'a> { | ||
fn register_boxed_model(&mut self, model: Box<dyn fj::models::Model>) { | ||
self.model = Some(model); | ||
} | ||
} | ||
|
||
impl<'a> fj::models::Context for Host<'a> { | ||
fn get_argument(&self, name: &str) -> Option<&str> { | ||
self.args.get(name).map(|s| s.as_str()) | ||
} | ||
} |
Oops, something went wrong.