added core docs

This commit is contained in:
Robin Müller 2022-06-11 12:27:03 +02:00
parent da30491cb9
commit 64899939b4
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 10 additions and 34 deletions

View File

@ -1,4 +1,12 @@
//! This module contains the core components of the Flight Software Rust Crate (FSRC) collection
//! This includes components to perform the following tasks
//!
//! 1. [Object Management][objects]
//! 2. [Task Scheduling][executable]
//! 3. [Events][event] and [event management][event_man]
//! 4. [Pre-Allocated memory pools][pool]
pub mod event_man; pub mod event_man;
pub mod events; pub mod events;
pub mod executable; pub mod executable;
pub mod objects; pub mod objects;
pub mod pool;

View File

@ -71,7 +71,7 @@ impl<E> EventManager<E> {
// To prevent double insertions // To prevent double insertions
for entry in vec.iter() { for entry in vec.iter() {
if entry.ltype == key && entry.dest.id() == dest.id() { if entry.ltype == key && entry.dest.id() == dest.id() {
return return;
} }
} }
vec.push(Listener { vec.push(Listener {

0
src/core/pool.rs Normal file
View File

View File

@ -1,35 +1,3 @@
use launchpad::core::events::{Event, Severity};
use std::sync::mpsc::channel;
use std::thread;
fn main() { fn main() {
basic_event_test(); println!("Hello World")
}
fn basic_event_test() {
let test_event_0 = Event::new(Severity::INFO, 0, 0);
let (event_sender, event_receiver) = channel();
let t0_sender = event_sender.clone();
let t0 = thread::spawn(move || {
t0_sender
.send(test_event_0.unwrap())
.expect("Sending event from t0 failed");
});
let test_event_1 = Event::new(Severity::MEDIUM, 1, 8);
let t1 = thread::spawn(move || {
event_sender
.send(test_event_1.unwrap())
.expect("Sending event from t1 failed");
});
let mut event_cntr = 0;
while event_cntr < 2 {
if let Ok(event) = event_receiver.recv() {
println!("Received event {:?}", event);
event_cntr += 1;
}
}
t0.join().unwrap();
t1.join().unwrap();
} }