Commit f3134b1b authored by Eisha Chen-yen-su's avatar Eisha Chen-yen-su

Introduce a backend command module

parent 6f39fb31
......@@ -7,6 +7,7 @@ use std::sync::{Arc, RwLock};
use crate::backend;
use crate::window;
use bkmessages::{BackendCommand, BackendUpdate};
pub fn launch() {
let app: gtk::Application =
......@@ -16,7 +17,7 @@ pub fn launch() {
let (cmd_sender, cmd_receiver) = channel::<String>();
let cmd_sender = Arc::new(RwLock::new(cmd_sender));
let (update_sender, update_receiver) = channel::<String>();
let (update_sender, update_receiver) = channel::<BackendUpdate>();
let update_receiver = Arc::new(RwLock::new(update_receiver));
backend::launch(cmd_receiver, update_sender);
......
......@@ -2,6 +2,9 @@ use std::sync::mpsc::{Receiver, Sender};
use std::thread;
pub fn launch(cmd_chan: Receiver<String>, update_chan: Sender<String>) {
use super::bkmessages::BackendUpdate;
pub fn launch(cmd_chan: Receiver<String>, update_chan: Sender<BackendUpdate>) {
thread::spawn(move || {
let mut count = 0;
......
pub enum BackendCommand {
Clear,
Randomize,
NextGen(u32),
}
pub enum BackendUpdate {
NewState(String),
Err(String),
}
......@@ -23,6 +23,7 @@ macro_rules! clone {
mod app;
mod backend;
mod bkmessages;
mod static_resource;
mod window;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment