Parma Polyhedra Library requirements
Generic threshold-watcher notification interfaces

Generic threshold-watcher notification interfaces

UID:
VERSION:
CLASSIFICATION:
PREFIX:
Type
Level
MID
UID
REFS
Title
Statement
Rationale
Comment
BIBLIOGRAPHY
STATUS
COMPONENT
APPLICABILITY
VERIFICATION_METHODS
VERIFICATION_CRITERIA
SOURCE
LANGUAGE
VISIBILITY
INTERFACE
SW_SPEC
1
PPL-SPEC-000851
Generic threshold-watcher traits and admitted value protocol

Threshold_Watcher<Traits> shall use the selected trait's Threshold and Delta types, current-value provider get(), nonthrowing strict comparison less_than and conversion from_delta. Threshold shall be default constructible, have nonthrowing copy construction, assignment and destruction, and satisfy its own value/resource needs. get() shall produce a value/reference bindable to a const threshold reference for the duration of a check. Conversion shall assign the selected absolute threshold from the supplied delta. Default construction, current-value provision and conversion may report exceptions.

The comparison shall provide a coherent strict order over the admitted current/pending domain, including false on equal values. The trait shall provide a writable check_function slot accepting, converting to and invocable as void (*)(), initially null with no pending events and owned by the watcher protocol while events remain. This generic mechanism shall require no timer availability or global PPL initialization beyond its selected traits' needs. Thread/lifetime conditions shall retain 🔗 12. Watcher notification lifetimes and exclusive use.

The generic watcher needs exact trait operations and failure/lifetime conditions independently of the computational-weight backend.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Instantiate independent strict-order traits, including nondefault delta types, throwing threshold-default/get/conversion operations and no PPL initialization.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

template <typename Traits> class Threshold_Watcher;
SW_SPEC
2
PPL-SPEC-000852
PPL-SPEC-000852
Flag-notification watcher construction

Successful flag-form construction shall own one handler bound to the supplied holder and flag under 🔗 2. Flag-handler binding and binding-preserving copies and 🔗 3. Strict-priority flag installation, compute/validate the event threshold under 🔗 4. Threshold conversion and already-reached rejection, and register exactly one pending event. Construction shall not install the flag or query its priority merely to register the event. The holder/flag shall remain borrowed notification objects. Failure shall retain 🔗 10. Construction failure cleanup and existing-event preservation.

In a thread-safe build an additional overload shall borrow an atomic pointer holder and a compatible flag. Its synchronous notification shall use release compare-and-exchange to fill only a null holder. It shall not dereference an existing request, query priorities, or replace a nonnull request. Both notification objects shall outlive the watcher; a published flag shall also outlive its readers. Cancellation shall precede clearing or releasing its binding. The same threshold validation, registration failure cleanup and queue exclusivity conditions shall apply.

Flag notification registration and actual priority-based installation occur at different times.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check initial holder/priority state, exact-deadline notification, cancellation, shared flags, callback isolation and construction failures.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc; tests/atomicwatchdogspec1.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

template <typename Flag_Base, typename Flag>
Threshold_Watcher(const typename Traits::Delta& delta,
                  const Flag_Base* volatile& holder, Flag& flag);

// Thread-safe builds only.
template <typename Flag_Base, typename Flag>
Threshold_Watcher(const typename Traits::Delta& delta,
                  std::atomic<const Flag_Base*>& holder, Flag& flag);
SW_SPEC
3
PPL-SPEC-000853
PPL-SPEC-000853
Function-notification watcher construction

Successful function-form construction shall own one handler retaining the supplied callback under 🔗 4. Function-handler target binding and copies and 🔗 5. Function action dispatch and callback failure, compute/validate its threshold under 🔗 4. Threshold conversion and already-reached rejection, and register exactly one pending event. The callback shall be live and nonnull when its event can dispatch. Construction shall not invoke it. Failure shall retain 🔗 10. Construction failure cleanup and existing-event preservation.

Registering a callback must preserve its identity without executing the notification prematurely.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Use distinct callbacks and before/equal/after threshold checks, cancellation and failure/retry histories with exact invocation counts.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

Threshold_Watcher(const typename Traits::Delta& delta, void (*function)());
SW_SPEC
4
PPL-SPEC-000854

Construction shall default-construct a local threshold, invoke the selected from_delta conversion, then obtain the current value and accept the result only if the current value is strictly before that threshold under the admitted comparison. A converted threshold equal to or before the current value shall throw std::invalid_argument and shall not register an event. Exceptions from default construction, conversion or current-value provision shall propagate with 🔗 10. Construction failure cleanup and existing-event preservation. The generic watcher shall not infer another numeric interpretation of a user-defined delta or absolute threshold.

An already reached threshold must be rejected before it becomes an active event, regardless of how the trait expresses deltas.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check future/equal/past conversions, zero deltas for additive traits, conversion order and each supported pre-registration exception.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

template <typename Traits> class Threshold_Watcher;
// Both constructors apply Traits::from_delta, Traits::get and
// Traits::less_than under the trait protocol above.
SW_SPEC
5
PPL-SPEC-000855
PPL-SPEC-000855
Per-trait event ordering and multiplicity

Watchers shall share their trait's pending queue within the storage policy in 🔗 12. Watcher notification lifetimes and exclusive use: one per thread for an opted-in thread-safe trait, otherwise one shared queue per trait. Each successful construction shall add one event, preserving all existing watchers and nondecreasing threshold order under 🔗 7. Sorted insertion and equivalent-deadline multiplicity. Equivalent future thresholds shall be admitted as distinct events; no relative dispatch order among equivalent events shall be required. Different trait instantiations shall have independent queues and hook slots. Registration shall not dispatch existing events.

Multiple pending events need independent identities even when their thresholds agree.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Compare distinct/equivalent threshold sets with an independent event model, interleave trait instantiations and preserve existing events through insert/cancel histories.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

template <typename Traits> class Threshold_Watcher;
SW_SPEC
6
PPL-SPEC-000856
Published checking function and empty-queue transitions

After successful event registration, the trait's check_function slot shall point to that instantiation's checking action. It shall remain published while any event is pending and become null when the final pending event is canceled or successfully dispatched. Failed construction shall preserve the previous slot value under 🔗 10. Construction failure cleanup and existing-event preservation. Clients shall invoke a published hook only while its queue remains nonempty under the exclusive-use protocol; retaining an old nonnull pointer shall not authorize calling an emptied queue.

A null hook prevents checkpoint dispatch from entering an empty queue.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check null/non-null transitions after every registration, cancel, failure and expiration, including previously captured pointer identity while events remain.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

// Trait protocol: call Traits::check_function() only while its
// published void (*)() slot is nonnull and remains current.
SW_SPEC
7
PPL-SPEC-000857
PPL-SPEC-000857
Due-event dispatch and successful expiration

A published check shall obtain the current object from one get() call and inspect pending events in threshold order. While that observed current object is not strictly before the first pending threshold, it shall invoke the event's bound action. Only after that action returns normally shall it mark the watcher expired and remove its pending event. Thus an event exactly at the current threshold shall be due. Processing shall stop at the first future event or an empty queue, retaining 🔗 6. Published checking function and empty-queue transitions.

If a trait returns a reference to mutable current state, later comparisons in the same dispatch shall observe any admitted serial changes to that object; a value returned by get() shall instead remain the retained value for that check. This mechanism shall not promise elapsed-time notification or invoke the current-value provider separately per event.

Expiration must follow successful notification and use the selected current-value binding semantics.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check before/equal/after and several due events, exact action counts, retained future events, one get call, and reference/value provider behavior after a callback advances current state.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

// Invoke the currently published Traits::check_function hook.
SW_SPEC
8
PPL-SPEC-000858
PPL-SPEC-000858
Action exceptions and partially completed dispatch

If a notification action throws, dispatch shall propagate that exception without marking or removing the throwing event. Earlier events already notified successfully shall remain expired and removed; later events shall remain pending. The throwing event's callback effects shall not be rolled back. A later admitted check may invoke it again, or destruction may cancel it. The queue and published hook shall remain consistent with the events still pending, and no handler shall leak.

Cooperative notification may throw to return control while preserving which events have actually completed.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Use a distinct prefix, throwing middle callback and later event; check exception identity/effects, pending hook, retry and cancellation without duplicate notification of the completed prefix.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

// Exception outcome of the currently published checking hook.
SW_SPEC
9
PPL-SPEC-000859
PPL-SPEC-000859
Watcher destruction, cancellation and handler ownership

Destruction of an unexpired watcher shall cancel its pending event; destruction of an already expired watcher shall not remove another event or notify again. Both shall destroy the watcher-owned handler exactly once. Cancellation shall not invoke the handler or modify external flag objects, and shall retain the active/free queue ownership of 🔗 9. Active-event erasure and successor preservation. Destruction shall retain the admitted nonthrowing trait operations and exclusive-use conditions.

The watcher owns its action wrapper, while cancellation and completed-expiration cleanup have different queue effects.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Cancel first/middle/last and sole events, destroy expired watchers in several orders, count handler/storage lifetimes and retain unrelated events.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

~Threshold_Watcher();
SW_SPEC
10
PPL-SPEC-000860

A reported failure while allocating the handler, default-constructing or converting a threshold, obtaining current state, rejecting an already reached threshold, or allocating its pending node shall release the incomplete watcher-owned handler and any temporary resources acquired for that construction. It shall preserve all previously pending watchers, their notification state and the previously published checking hook. The same trait instantiation shall permit later successful construction and dispatch/cancellation. The nonthrowing copy/assignment/destruction/ comparison prerequisites shall remain those of 🔗 1. Generic threshold-watcher traits and admitted value protocol.

All pre-registration failure paths must relinquish the newly allocated handler without disturbing existing event owners.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Inject each observable allocation and supported threshold-default/get/conversion failure for both constructor forms, preserve existing event identities/hook/flags and retry.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

template <typename Flag_Base, typename Flag>
Threshold_Watcher(const typename Traits::Delta& delta,
                  const Flag_Base* volatile& holder, Flag& flag);
Threshold_Watcher(const typename Traits::Delta& delta, void (*function)());
SW_SPEC
11
PPL-SPEC-000861
PPL-SPEC-000861
Noncopyable watcher lifetime identity

A watcher shall retain one lifetime identity for its expired flag, handler and pending position. Copy construction and assignment shall be inaccessible; no public move construction/assignment or default construction shall be supplied. Clients shall keep its address and lifetime stable while an event can reference that state. Separate watcher objects shall be constructed through their own notification constructors.

Memberwise copying would duplicate a queue position and references to one watcher's expiration state.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Check public construction/copy/move traits and independent event ownership of separately constructed watchers.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

template <typename Traits> class Threshold_Watcher;
// Public construction is limited to the two notification forms above.
SW_SPEC
12
PPL-SPEC-000862

Construction, destruction and checks for one trait's shared queue shall not overlap concurrently or reenter that queue's dispatch. Notification actions shall retain the valid handler/flag/function bindings of 🔗 1. Polymorphic event-action interface and virtual destruction, 🔗 2. Flag-handler binding and binding-preserving copies, 🔗 3. Strict-priority flag installation, 🔗 4. Function-handler target binding and copies and 🔗 5. Function action dispatch and callback failure and shall not destroy a watcher whose handler or expiration state is being accessed. The trait's current-value result shall remain valid through its use. Clients shall not replace a queue's hook while its events remain.

In a thread-safe configuration, a trait may opt into per-thread queues with static constexpr bool thread_local_queue = true. Its current-value state and checking slot shall then also be thread-local. Weightwatch_Traits shall use this policy. Watchers and their borrowed bindings shall remain in their constructing thread and be destroyed before that thread exits. Other threads may independently compute, register, cancel and check their own queues. Exclusivity and nonreentrancy shall apply separately to each queue. Traits without that opt-in, and ordinary non-thread-safe configurations, shall retain the shared-state synchronization requirements above.

Queue state, callback execution and borrowed watcher fields must remain live under the configured queue's single-owner protocol.

APPROVED
RUNTIME
IF_CPP
Test, Analysis, Inspection

Inspect actual queue/handler accesses and trait storage policy. Exercise serial shared traits and simultaneous per-thread weightwatch queues, including independent cancellation and expiry, without destroying executing actions.

src/Threshold_Watcher_defs.hh; src/Threshold_Watcher_inlines.hh; src/Threshold_Watcher_templates.hh; src/Pending_List_defs.hh; tests/thresholdwatcherspec1.cc; tests/thresholdwatcherlegacy1.cc; tests/thresholdwatcherlegacy1_handler.cc; tests/weightwatchspec1.cc.

CPP
Public

Public C++ header: ppl.hh; defining source header: Threshold_Watcher_defs.hh. The template belongs to Parma_Polyhedra_Library. Member excerpts apply to Threshold_Watcher<Traits>; hook expressions describe the required trait-owned callback-slot protocol.

template <typename Traits> class Threshold_Watcher;