Skip to content

Commit 0ac1aaf

Browse files
committed
[update] all runtime definitions and fix imports/directories.
1 parent bf99c0d commit 0ac1aaf

6 files changed

Lines changed: 24 additions & 24 deletions

File tree

lambda/src/core/kernel.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

lambda/src/core/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub mod component;
22
pub mod events;
3-
pub mod kernel;
43
pub mod render;
4+
pub mod runtime;
55
pub mod window;

lambda/src/core/runtime.rs

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

lambda/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pub mod components;
22
pub mod core;
3-
pub mod kernels;
3+
pub mod runtimes;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use crate::core::{
1818
RuntimeEvent,
1919
WindowEvent,
2020
},
21-
kernel::Runtime,
2221
render::{
2322
window::{
2423
Window,
@@ -27,6 +26,7 @@ use crate::core::{
2726
RenderContext,
2827
RenderContextBuilder,
2928
},
29+
runtime::Runtime,
3030
};
3131

3232
pub struct GenericRuntimeBuilder {

tools/lambda_rs_demo/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use lambda::{
77
RenderableComponent,
88
},
99
events::Events,
10-
kernel::start_runtime,
1110
render::{
1211
command::RenderCommand,
1312
pipeline::{
@@ -26,8 +25,9 @@ use lambda::{
2625
},
2726
viewport,
2827
},
28+
runtime::start_runtime,
2929
},
30-
kernels::GenericRuntimeBuilder,
30+
runtimes::GenericRuntimeBuilder,
3131
};
3232

3333
pub struct DemoComponent {

0 commit comments

Comments
 (0)