pub struct MonitorEvent {
pub snapshot: Arc<Snapshot>,
pub origin: u64,
pub mask: EventMask,
}Expand description
A monitor event sent to subscribers when a PV value changes. Carries a full Snapshot so GR/CTRL metadata (PREC, EGU, limits) is available.
Fields§
§snapshot: Arc<Snapshot>The posted value, shared with every other subscriber this post reached.
C never copies a wide value into an event at all. db_create_field_log
stores anything wider than union native_value by reference
(dbfl_type_ref, dtor == NULL, so dbfl_has_copy is false), and the
value is read at DELIVERY: read_reply reserves the payload inside the
client’s existing send buffer (cas_copy_in_header,
camessage.c:516) and dbGet converts straight from the record’s live
field into it (dbAccess.c:1020, the !dbfl_has_copy(pfl) arm). One
array, N events pointing at it, zero retained copies.
The port cannot read the record at delivery — the event outlives the
record lock — so it snapshots once at post time. Arc is what makes
that snapshot C’s single array instead of one owned copy per
subscriber: record_instance built make_monitor_snapshot once and
then deep-cloned it per subscriber, so a 1 MiB waveform with four
monitors cost 4 MiB retained where C costs four ~100-byte field logs.
Measured consequence on x86_64-wrs-vxworks: memory allocation of 1048576 bytes failed and signal 6 at fan-out 4, while the same four
clients without array monitors survived at a HIGHER MEM_USED
(213,311,488 B vs the 211,804,160 B the aborting run died at) — the
fan-out was the discriminator, not the memory level.
origin: u64Origin writer ID. When non-zero, subscribers with the same
ignore_origin can filter out self-triggered events.
Used to prevent sequencer write-back loops.
Scope: tagged explicitly by the put_*_post tier
(put_pv_and_post_with_origin, records and simple PVs alike), and
inherited by every post inside the put_*_process tier’s
synchronous put+process cascade through the thread-local ambient
write origin (AmbientWriteOriginScope) — both record funnels
(notify_field_with_origin, notify_from_snapshot) and the
simple-PV funnel (ProcessVariable::deliver) apply the same
inheritance rule. Posts from work a cascade merely spawned (async
record completions, driver pollers) run outside any scope and stay
origin 0.
mask: EventMaskThe DBE_* event class(es) this post carries FOR THIS SUBSCRIBER
— the poster’s mask intersected with the subscriber’s select,
never the poster’s mask alone. C stamps exactly that on the field
log (pLog->mask = caEventMask & pevent->select,
dbEvent.c:896-900) and pvxs narrows per event from
pDbFieldLog->mask (groupsource.cpp:331-337). The intersection
is produced by Subscriber::delivered_mask, which is also the
delivery gate, so the two cannot drift apart. Carrying it on the
event lets subscribers narrow what they decode (e.g. a QSRV group
monitor updating only alarm leaves on a DBE_ALARM-only event)
and lets the .{dbnd}/.{sync}/.{dec} pre-chain filters see the
classes the client actually asked for.
When events coalesce under a slow consumer, masks accumulate by
OR — the surviving snapshot is the newest, the mask reports every
class that changed since the last delivered event.
Trait Implementations§
Source§impl Clone for MonitorEvent
impl Clone for MonitorEvent
Source§fn clone(&self) -> MonitorEvent
fn clone(&self) -> MonitorEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more