DescriptorDrain
Reads a descriptor until it is told to stop, and proves it has stopped before the descriptor can be closed.
Source and package
- Qualified name
-
DescriptorDrain - Package
- libtmux-swift
- Source
- Tests/TmuxFixture/DescriptorDrain.swift
- class DescriptorDrain : class Descriptor
Drain -
Description#
Draining a pseudo-terminal keeps its client from blocking on a full buffer. A reader that loops on
read(descriptor)while another thread closes the descriptor does not stop: its next call lands on whatever the process opened next under the same number, and it consumes that file's bytes. In a suite that spawns tmux servers concurrently, the number is soon a pipe carrying another case's reply, so a listing arrives short or a command's marker line never arrives, in a case that has nothing to do with this one.stop()returns only after the reader has left its loop, so the caller can close the descriptor afterwards without a reader outliving it.
Members2#
- init(reading:) method Starts reading
descriptor, which the caller keeps open untilstop()has returned. The descriptor is made non-blocking so the reader can notice a stop request instead of sitting inreadthrough it. - stop() method Stops the reader and waits until it has exited. Safe to call once.