mirror of
https://github.com/wez/wezterm.git
synced 2024-12-26 14:54:16 +03:00
add MuxExecutor
This commit is contained in:
parent
0eb7f05eff
commit
05c14e5bc7
@ -6,24 +6,53 @@ use crate::mux::tab::Tab;
|
|||||||
use crate::mux::Mux;
|
use crate::mux::Mux;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use promise::Executor;
|
use promise::Executor;
|
||||||
|
use promise::SpawnFunc;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::sync::mpsc::{self, Receiver, SyncSender};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct MuxServerFrontEnd {}
|
#[derive(Clone)]
|
||||||
|
struct MuxExecutor {
|
||||||
|
tx: SyncSender<SpawnFunc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Executor for MuxExecutor {
|
||||||
|
fn execute(&self, f: SpawnFunc) {
|
||||||
|
self.tx.send(f).expect("GlutinExecutor execute failed");
|
||||||
|
}
|
||||||
|
fn clone_executor(&self) -> Box<Executor> {
|
||||||
|
Box::new(MuxExecutor {
|
||||||
|
tx: self.tx.clone(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MuxServerFrontEnd {
|
||||||
|
tx: SyncSender<SpawnFunc>,
|
||||||
|
rx: Receiver<SpawnFunc>,
|
||||||
|
}
|
||||||
|
|
||||||
impl MuxServerFrontEnd {
|
impl MuxServerFrontEnd {
|
||||||
pub fn try_new(_mux: &Rc<Mux>) -> Result<Rc<FrontEnd>, Error> {
|
pub fn try_new(_mux: &Rc<Mux>) -> Result<Rc<FrontEnd>, Error> {
|
||||||
Ok(Rc::new(Self {}))
|
let (tx, rx) = mpsc::sync_channel(4);
|
||||||
|
Ok(Rc::new(Self { tx, rx }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FrontEnd for MuxServerFrontEnd {
|
impl FrontEnd for MuxServerFrontEnd {
|
||||||
fn gui_executor(&self) -> Box<Executor> {
|
fn gui_executor(&self) -> Box<Executor> {
|
||||||
unimplemented!();
|
Box::new(MuxExecutor {
|
||||||
|
tx: self.tx.clone(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_forever(&self) -> Result<(), Error> {
|
fn run_forever(&self) -> Result<(), Error> {
|
||||||
unimplemented!();
|
loop {
|
||||||
|
match self.rx.recv() {
|
||||||
|
Ok(func) => func.call(),
|
||||||
|
Err(err) => bail!("while waiting for events: {:?}", err),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_new_window(
|
fn spawn_new_window(
|
||||||
|
Loading…
Reference in New Issue
Block a user