mux: Mux is now Send+Sync

This commit is contained in:
Wez Furlong committed 2022-12-19 11:54:02 -07:00
1 parent ee2aac0902
commit 478cc59be3
11 files changed
+128 -126

No files matched your search

+2 -2
View File
@@ -9,7 +9,7 @@ use mux::window::{Window, WindowId};
use mux::Mux;
use portable_pty::CommandBuilder;
use std::collections::HashMap;
use std::rc::Rc;
use std::sync::Arc;
use wezterm_dynamic::{FromDynamic, ToDynamic};
use wezterm_term::TerminalSize;
@@ -21,7 +21,7 @@ pub use pane::MuxPane;
pub use tab::MuxTab;
pub use window::MuxWindow;
fn get_mux() -> mlua::Result<Rc<Mux>> {
fn get_mux() -> mlua::Result<Arc<Mux>> {
Mux::get()
.ok_or_else(|| mlua::Error::external("cannot get Mux: not running on the mux thread?"))
}
+1 -1
View File
@@ -6,7 +6,7 @@ use std::sync::Arc;
pub struct MuxPane(pub PaneId);
impl MuxPane {
pub fn resolve<'a>(&self, mux: &'a Rc<Mux>) -> mlua::Result<Arc<dyn Pane>> {
pub fn resolve<'a>(&self, mux: &'a Arc<Mux>) -> mlua::Result<Arc<dyn Pane>> {
mux.get_pane(self.0)
.ok_or_else(|| mlua::Error::external(format!("pane id {} not found in mux", self.0)))
}
+1 -1
View File
@@ -5,7 +5,7 @@ use std::sync::Arc;
pub struct MuxTab(pub TabId);
impl MuxTab {
pub fn resolve<'a>(&self, mux: &'a Rc<Mux>) -> mlua::Result<Arc<Tab>> {
pub fn resolve<'a>(&self, mux: &'a Arc<Mux>) -> mlua::Result<Arc<Tab>> {
mux.get_tab(self.0)
.ok_or_else(|| mlua::Error::external(format!("tab id {} not found in mux", self.0)))
}
+5 -2
View File
@@ -5,14 +5,17 @@ use parking_lot::{MappedRwLockReadGuard, MappedRwLockWriteGuard};
pub struct MuxWindow(pub WindowId);
impl MuxWindow {
pub fn resolve<'a>(&self, mux: &'a Rc<Mux>) -> mlua::Result<MappedRwLockReadGuard<'a, Window>> {
pub fn resolve<'a>(
&self,
mux: &'a Arc<Mux>,
) -> mlua::Result<MappedRwLockReadGuard<'a, Window>> {
mux.get_window(self.0)
.ok_or_else(|| mlua::Error::external(format!("window id {} not found in mux", self.0)))
}
pub fn resolve_mut<'a>(
&self,
mux: &'a Rc<Mux>,
mux: &'a Arc<Mux>,
) -> mlua::Result<MappedRwLockWriteGuard<'a, Window>> {
mux.get_window_mut(self.0)
.ok_or_else(|| mlua::Error::external(format!("window id {} not found in mux", self.0)))