Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions libtmux-kotlin/src/main/kotlin/io/github/libtmux/kotlin/Server.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ import io.github.libtmux.Session as JavaSession
import io.github.libtmux.Window as JavaWindow

/**
* One tmux server, reached over one transport.
* Manages sessions, windows, and panes on a tmux server.
*
* Holds the Java handle privately: this is a wrapper, not [JavaServer] itself, so a member here
* always wins over a same-named catalog-generated extension (see `ServerOperations.kt`) and a query
* field lives on [Companion] rather than colliding with an instance member.
* Use [open] with a [ServerConfig] to select a server by socket name or path. From this object,
* create sessions or query the server's existing sessions, windows, and panes. Each [Session]
* contains windows, and each [Window] contains panes.
*
* Every operation that may contact tmux is `suspend`, dispatched through [policy]. Close it once,
* after the last call on any thread — the same threading contract [JavaServer] documents.
* Operations that contact tmux are `suspend` functions dispatched through [policy]. Call [close]
* after the last operation to release resources owned by this object. The tmux server and its
* sessions keep running.
*
* [asJava] exposes the underlying [JavaServer] for interoperability. Both objects share the same
* resources, so closing either closes both.
*/
public class Server private constructor(
internal val java: JavaServer,
Expand Down
10 changes: 7 additions & 3 deletions libtmux/src/main/java/io/github/libtmux/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@
import org.jspecify.annotations.Nullable;

/**
* One tmux server, reached over one transport.
* Manages sessions, windows, and panes on a tmux server.
*
* <p>Use {@link #open} with a {@link ServerConfig} to select a server by socket name or path.
* From this object, create sessions or query the server's existing sessions, windows, and panes.
* Each {@link Session} contains windows, and each {@link Window} contains panes.
*
* <p>Ownership is decided at construction and never inferred. {@link #open} creates a transport this
* server closes exactly once; {@link #using} borrows one the caller keeps, so several servers can
* share a transport and closing one leaves the others working.
*
* <p>Closing a server closes a client, not a tmux. It never kills the server process: sessions
* outlive the program that made them, which is the entire point of tmux.
* <p>Closing this object releases its owned transport. The tmux server and its sessions keep
* running. Call {@link #killServer()} to stop the tmux server.
*
* <p>Close it anyway. A server that owns its transport holds the threads that drain tmux's output,
* and those are not daemons, so that a reply being read when a program ends is finished rather than
Expand Down
Loading