|
gstreamer
|
One crate's bounded input queue, ordering buffer, and background processing thread. More...
#include <gSROCrate.h>
Data Structures | |
| class | Impl |
Public Types | |
| using | ResourceFactory = std::function<GSROCrateResources()> |
| using | DeliveryCallback = std::function<void(GSROEventId, std::uint64_t)> |
| using | FailureCallback = std::function<void(std::exception_ptr)> |
Public Member Functions | |
| GSROCrate (GSROCrateId crate_id, ResourceFactory make_resources, GSROCrateLimits limits={}, DeliveryCallback on_delivery={}, FailureCallback on_failure={}) | |
| ~GSROCrate () | |
| GSROCrate (const GSROCrate &)=delete | |
| GSROCrate & | operator= (const GSROCrate &)=delete |
| GSROCrate (GSROCrate &&)=delete | |
| GSROCrate & | operator= (GSROCrate &&)=delete |
| void | enqueue_payload (GSROPayload payload) |
| Transfers ownership. Rejects null data, wrong crates, oversized input, and timestamps before a boundary. | |
| void | advance_time (GSROTime safe_time) |
| Queue a nondecreasing boundary after all earlier input has been submitted. Equality is permitted. | |
| void | request_finish (GSROEndContext context) |
| Close input and wake producers without joining; permits a service to stop every crate before waiting. | |
| void | cancel (std::exception_ptr error) |
| Fail input and wake waiters. Cleanup runs on the crate thread after any executing callback returns. | |
| void | finish_and_join (GSROEndContext context) |
| void | rethrow_if_failed () const |
| Check for a background failure without waiting. Failure also wakes and rejects queued producers. | |
Upcoming in the next release. Construction starts the thread; make_resources runs there and returns the sink and the plugin bound to that sink. Their callbacks and destruction also run on that thread. Keep implementation libraries loaded until this object is destroyed.
enqueue_payload and advance_time support concurrent callers. The caller must establish global event delivery before submitting a safe-time boundary; this class does not calculate one. Producers may wait for queue space, but plugin callbacks and output never execute under the queue mutex.
Payloads awaiting a safe boundary have separate limits. Exceeding them fails the crate instead of blocking its consumer and preventing earlier input from arriving. These limits do not bound memory retained inside the implementation plugin; a global admission policy remains a service-level concern.
on_delivery acknowledges retention in the ordering buffer, not plugin processing or durable output. It runs on the crate thread and must not block or call back into this crate. It may notify a future event-delivery tracker. Its exceptions fail the crate just like plugin exceptions. on_failure runs after a background failure, outside the queue mutex. It must not throw, block, or join crate threads. A service may use it to cancel other crates; notification exceptions are suppressed.
The owner must serialize finish_and_join calls and destruction, and keep this object alive until all producers have returned. Callbacks must terminate; joining cannot interrupt a hung plugin or system call.
Definition at line 71 of file gSROCrate.h.
| using GSROCrate::DeliveryCallback = std::function<void(GSROEventId, std::uint64_t)> |
Definition at line 75 of file gSROCrate.h.
| using GSROCrate::FailureCallback = std::function<void(std::exception_ptr)> |
Definition at line 76 of file gSROCrate.h.
| using GSROCrate::ResourceFactory = std::function<GSROCrateResources()> |
Definition at line 74 of file gSROCrate.h.
| GSROCrate::GSROCrate | ( | GSROCrateId | crate_id, |
| ResourceFactory | make_resources, | ||
| GSROCrateLimits | limits = {}, | ||
| DeliveryCallback | on_delivery = {}, | ||
| FailureCallback | on_failure = {} ) |
Definition at line 223 of file gSROCrate.cc.
| GSROCrate::~GSROCrate | ( | ) |
Definition at line 228 of file gSROCrate.cc.
|
delete |
|
delete |
| void GSROCrate::advance_time | ( | GSROTime | safe_time | ) |
Definition at line 234 of file gSROCrate.cc.
| void GSROCrate::cancel | ( | std::exception_ptr | error | ) |
Definition at line 236 of file gSROCrate.cc.
| void GSROCrate::enqueue_payload | ( | GSROPayload | payload | ) |
Definition at line 233 of file gSROCrate.cc.
| void GSROCrate::finish_and_join | ( | GSROEndContext | context | ) |
Stop accepting input, wake producers, drain, finalize, and join. Repeated calls only recheck errors. A supplied boundary must not precede any submitted boundary; absence preserves the latest one. Pending payloads reach the plugin before finish_run, leaving unfinished-frame policy to it. Rethrows background errors after joining. The destructor instead performs interrupted shutdown and suppresses errors, so explicit finalization is required to observe write/close failures.
Definition at line 237 of file gSROCrate.cc.
| void GSROCrate::request_finish | ( | GSROEndContext | context | ) |
Definition at line 235 of file gSROCrate.cc.
| void GSROCrate::rethrow_if_failed | ( | ) | const |
Definition at line 238 of file gSROCrate.cc.