You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
1.8 KiB

#![cfg_attr(nightly, feature(int_error_matching))]
#![cfg_attr(nightly, feature(const_fn))]
#![cfg_attr(nightly, feature(maybe_uninit_ref))]
#![allow(dead_code)]
use tokio::{
select,
time::{
self,
Duration,
},
sync::{
mpsc,
},
task,
};
mod util;
use util::*;
mod log;
mod interval;
mod config;
mod live;
mod context;
mod job;
async fn do_thing_every() -> Result<(mpsc::Sender<()>, task::JoinHandle<()>), Box<dyn std::error::Error>>
{
let mut interval = time::interval(Duration::from_secs(10));
let (tx, mut rx) = mpsc::channel(16);
let handle = tokio::spawn(async move {
println!("starting?");
loop {
let mut tick = interval.tick();
tokio::pin!(tick);
loop {
select!{
_ = &mut tick => {
// Do the things
println!("yes");
break;
}
command = rx.recv() => {
// We got interrupt, interpret `command` here.
// `continue` to continue waiting on this interval, break to go to next, return to stop
println!("no");
continue;
}
}
}
}
});
Ok((tx, handle))
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
log::init(log::Level::Debug);
debug!("Initialised");
let oneesan = live::watch(".");
{
let mut recv = oneesan.hook("src/main.rs", live::filter::ALL).await;
while let Some(event) = recv.recv().await
{
important!("Got ev {:?}", event);
break;
}
}
oneesan.shutdown().await.expect("oneesan panic");
println!("{:?}", config::parse_global_single("example.rori").await.expect("Waaaaaah"));
dangerous!("Wheeeee");
//let (mut tx, h) = do_thing_every().await?;
// loop {
// time::delay_for(Duration::from_secs(6)).await;
// tx.send(()).await?;
// }
// h.await?;
Ok(())
}