Skip to content

Commit 0ac5035

Browse files
committed
[update] location for runtime.
1 parent bf5b250 commit 0ac5035

File tree

10 files changed

+27
-7
lines changed

10 files changed

+27
-7
lines changed

crates/lambda-rs/examples/minimal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
#[macro_use]
77
use lambda::{
8-
core::runtime::start_runtime,
8+
runtime::start_runtime,
99
runtimes::ApplicationRuntimeBuilder,
1010
};
1111

crates/lambda-rs/examples/push_constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use lambda::{
22
component::Component,
3-
core::runtime::start_runtime,
43
events::WindowEvent,
54
math::{
65
matrix,
@@ -28,6 +27,7 @@ use lambda::{
2827
viewport,
2928
ResourceId,
3029
},
30+
runtime::start_runtime,
3131
runtimes::ApplicationRuntimeBuilder,
3232
};
3333
use lambda_platform::{

crates/lambda-rs/examples/triangle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use lambda::{
22
component::Component,
3-
core::runtime::start_runtime,
43
events::{
54
ComponentEvent,
65
Events,
@@ -20,6 +19,7 @@ use lambda::{
2019
viewport,
2120
RenderContext,
2221
},
22+
runtime::start_runtime,
2323
runtimes::ApplicationRuntimeBuilder,
2424
};
2525

crates/lambda-rs/examples/triangles.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use lambda::{
22
component::Component,
3-
core::runtime::start_runtime,
43
events::{
54
Events,
65
Key,
@@ -23,6 +22,7 @@ use lambda::{
2322
viewport,
2423
RenderContext,
2524
},
25+
runtime::start_runtime,
2626
runtimes::ApplicationRuntimeBuilder,
2727
};
2828

crates/lambda-rs/src/core/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
pub mod runtime;
21
pub mod window;

crates/lambda-rs/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ pub mod core;
44
pub mod events;
55
pub mod math;
66
pub mod render;
7+
pub mod runtime;
78
pub mod runtimes;

crates/lambda-rs/src/runtimes/application.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use lambda_platform::winit::{
1717

1818
use crate::{
1919
component::Component,
20-
core::runtime::Runtime,
2120
events::{
2221
Button,
2322
ComponentEvent,
@@ -35,6 +34,7 @@ use crate::{
3534
RenderContext,
3635
RenderContextBuilder,
3736
},
37+
runtime::Runtime,
3838
};
3939

4040
pub struct ApplicationRuntimeBuilder {

crates/lambda-rs/src/runtimes/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,23 @@ pub use application::{
33
ApplicationRuntime,
44
ApplicationRuntimeBuilder,
55
};
6+
7+
pub trait Runtime {
8+
fn on_start(&mut self);
9+
fn on_stop(&mut self);
10+
fn run(self);
11+
}
12+
13+
/// Builds & executes a runtime all in one good. It's a good idea to use this if you
14+
/// don't need to execute any code in between the building & execution stage of
15+
/// the runnable, but will not impact or modify the runtime in any way.
16+
pub fn build_and_start_kernel<T: Default + Runtime>() {
17+
let runtime = T::default();
18+
start_runtime(runtime);
19+
}
20+
21+
/// Simple function for starting any prebuilt Runnable.
22+
pub fn start_runtime<T: Runtime>(mut runtime: T) {
23+
runtime.on_start();
24+
runtime.run();
25+
}

tools/obj_loader/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use args::{
99
};
1010
use lambda::{
1111
component::Component,
12-
core::runtime::start_runtime,
1312
events::{
1413
ComponentEvent,
1514
Events,
@@ -45,6 +44,7 @@ use lambda::{
4544
viewport,
4645
ResourceId,
4746
},
47+
runtime::start_runtime,
4848
runtimes::ApplicationRuntimeBuilder,
4949
};
5050

0 commit comments

Comments
 (0)