server.Server.with_channel_lock
Rust
- Python Unavailable
- TypeScript Unavailable
- Rust
- Go Unavailable
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift Unavailable
- Module
- server
- Declared in
- Server
- Package
- libtmux
- Source
- crates/libtmux/src/server/channels.rs
-
Hold a
wait-forchannel for the length of an operation.Self::lock_channelandSelf::unlock_channelas a pair, so a locker that returns early, fails, or panics still releases the channel: a lock left held wedges every later locker on the server.Errors
crate::ScopeError::Creationwhen tmux refuses the lock or the lock runs out of time,Operationwhen the body fails, andCleanupwhen the unlock fails after the body succeeded.Cancel safety
Nothing is left held by a drop. The lock is taken and released in tasks of their own, so a scope dropped while its lock is still queued unlocks once tmux grants it, as
Self::lock_channeldescribes.Examples
let guard = libtmux::test::TestServer::new().await?;let server = guard.server();let count = server.with_channel_lock("deploy", async |server| {Ok::<_, libtmux::Error>(server.sessions().await?.len())}).await?;// The channel is free again, so the next locker is not blocked.server.lock_channel("deploy").await?;server.unlock_channel("deploy").await?;guard.shutdown().await?;
0 declared, 0 inherited