diff options
| author | Andrew Guschin <guschin@altlinux.org> | 2024-11-05 21:28:48 +0400 |
|---|---|---|
| committer | Andrew Guschin <guschin@altlinux.org> | 2024-11-05 21:28:48 +0400 |
| commit | 8117591bdbc5e168d91eac09316bc7e21068429b (patch) | |
| tree | 5b9dd8655b87e84e03df93a439ef82649a92dc4a | |
| parent | 67b2ce202097c4ce0db3ea81df775405608d527f (diff) | |
wipui
| -rw-r--r-- | graph-checker/src/compute.rs | 4 | ||||
| -rw-r--r-- | graph-checker/src/gui.rs | 18 | ||||
| -rw-r--r-- | graph-checker/src/main.rs | 3 |
3 files changed, 23 insertions, 2 deletions
diff --git a/graph-checker/src/compute.rs b/graph-checker/src/compute.rs index b43d64c..4d3a17a 100644 --- a/graph-checker/src/compute.rs +++ b/graph-checker/src/compute.rs @@ -1,6 +1,10 @@ use crate::graph::{Graph, GraphProfile}; use crate::theorems::{basic, forbidden, toughness}; +use std::sync::mpsc; + +pub fn producer(send: mpsc::Sender<GraphProfile>) {} + pub fn apply_theorems(g: Graph) -> GraphProfile { // let db = db.clone(); // counters.graphs += 1; diff --git a/graph-checker/src/gui.rs b/graph-checker/src/gui.rs index 2a363e2..d18523c 100644 --- a/graph-checker/src/gui.rs +++ b/graph-checker/src/gui.rs @@ -2,9 +2,13 @@ use crate::compute; use crate::geng::GengIterator; use crate::graph; use eframe::egui; +use futures::executor::block_on; use std::sync::mpsc; use std::time::{Duration, Instant}; use tokio; +// use tokio::sync::mpsc; + +pub enum ComputeMessage pub fn run_gui(rt: tokio::runtime::Runtime) { let options = eframe::NativeOptions::default(); @@ -52,21 +56,31 @@ impl<'a> ComputeWindow<'a> { } } + fn compute_graphs(&mut self) {} + fn update(&mut self, ui: &mut egui::Ui) { if ui.button("Посчитать графы").clicked() { - let gi = GengIterator::new(7); + let gi = GengIterator::new(4); let _tasks: Vec<_> = gi .map(|g| { // let db = db.clone(); let tx = self.tx.clone(); self.rt.spawn(async move { - tx.send(compute::async_theorems1(g).await).unwrap(); + let res = compute::async_theorems1(g).await; + println!("{res:?}"); + match tx.send(res) { + Ok(g) => println!("{g:?}"), + Err(e) => println!("{e}"), + } }) }) .collect(); + block_on(async { futures::future::join_all(_tasks).await }); + // let res = futures::future::join_all(_tasks).await; } if let Ok(p) = self.rx.recv_timeout(Duration::from_millis(10)) { + println!("push"); self.computed.push(p); } diff --git a/graph-checker/src/main.rs b/graph-checker/src/main.rs index e73b23b..4297a6e 100644 --- a/graph-checker/src/main.rs +++ b/graph-checker/src/main.rs @@ -2,6 +2,7 @@ use rayon::prelude::*; use sqlx::{migrate::MigrateDatabase, Pool, Sqlite}; // use std::sync::{Arc, Mutex}; +use std::sync::mpsc; use std::time::Instant; use tokio; @@ -41,6 +42,8 @@ fn main() -> Result<(), sqlx::Error> { Ok::<Pool<Sqlite>, sqlx::Error>(db) })?; + let (tx, rx) = mpsc::channel(); + gui::run_gui(rt); // let gui_task = tokio::spawn(gui::run_gui()); println!("next"); |