|
Wireshark 4.7.2
The Wireshark network protocol analyzer
|
Worker that runs a dumpcap "-S" statistics stream off the GUI thread. More...
#include <interface_stats_worker.h>
Public Slots | |
| void | start () |
| Opens the dumpcap statistics stream and begins periodic sampling. | |
| void | stop () |
| Stops sampling and tears down the dumpcap stream and process. | |
| void | setInterfaceFilter (const QStringList &interfaceNames) |
| Restricts which interfaces appear in emitted snapshots. | |
| void | setUpdateInterval (int intervalMsec) |
| Sets the pipe-drain/emit interval. | |
| void | pause () |
| Tears down the dumpcap stream but remembers the configuration. | |
| void | resume () |
| Re-opens the stream previously suspended with pause(). | |
Signals | |
| void | started () |
| Emitted once the dumpcap stream has been opened successfully. | |
| void | stopped () |
| Emitted after the stream and process have been torn down. | |
| void | failed (int exitCode, const QString &errorMessage) |
| Emitted when the stream could not be opened or has broken. | |
| void | sampled (const InterfaceStatsSnapshot &snapshot) |
| Emitted each cycle in which new counters were read. | |
Public Member Functions | |
| InterfaceStatsWorker (QObject *parent=nullptr) | |
| Constructs an idle worker with the default update interval. | |
| ~InterfaceStatsWorker () override | |
| Stops the stream (if running) and destroys the worker. | |
| int | updateInterval () const |
| Returns the current pipe-drain/emit interval, in milliseconds. | |
Worker that runs a dumpcap "-S" statistics stream off the GUI thread.
The worker is designed to be moved onto a dedicated QThread. It owns the dumpcap child process and its stat pipe, drains the pipe on a timer, and emits a snapshot of the latest per-interface counters. It deliberately knows nothing about the interface model, views, or the global capture options: the application name is supplied by the caller so the same worker serves both Wireshark and Stratoshark.
Threading contract: every public slot is meant to be invoked through the worker thread's event loop (queued/auto connections or QMetaObject::invokeMethod), never called directly across threads. The slots assert this.
Lifetime/teardown: the worker creates no thread of its own; an owner moves it onto a dedicated QThread and is responsible for destroying it safely using the standard idiom, so the destructor (and thus closeStream()) runs on the worker's own thread:
The destructor asserts it is run on the worker's own thread to catch misuse. This worker is not a singleton: exactly one instance is expected, owned by the (single) statistics facade, never instantiated ad hoc.
|
explicit |
Constructs an idle worker with the default update interval.
| parent | Optional parent QObject. Leave null when the worker will be moved to its own thread. |
|
signal |
Emitted when the stream could not be opened or has broken.
| exitCode | Numerical exit code from the stats process. |
| errorMessage | Human-readable description. |
|
slot |
Tears down the dumpcap stream but remembers the configuration.
Used to stop sampling (and free the dumpcap process) without forgetting the application name or filter, e.g. while a capture is active. resume() re-opens the stream. A no-op if not currently running.
|
slot |
Re-opens the stream previously suspended with pause().
A no-op unless the worker is paused.
|
signal |
Emitted each cycle in which new counters were read.
| snapshot | Latest cumulative per-interface counters. |
|
slot |
Restricts which interfaces appear in emitted snapshots.
dumpcap reports counters for every interface it can open; this filter is applied only to the emitted snapshot. An empty list (the default) emits every reported interface.
| interfaceNames | Interface names to keep, or empty for all. |
|
slot |
Sets the pipe-drain/emit interval.
| intervalMsec | Interval in milliseconds; values < 1 are ignored. |
|
slot |
|
slot |
Stops sampling and tears down the dumpcap stream and process.
Clears the running state; a subsequent start() is required to resume.
| int InterfaceStatsWorker::updateInterval | ( | ) | const |
Returns the current pipe-drain/emit interval, in milliseconds.
Seeded from a built-in default at construction; overridable via setUpdateInterval() (e.g. from a preference).