tenzr::execution::ExecutionStream¶
Serialized work queue backed by a worker thread, used to submit and synchronize device work.
#include <stream.h>
Inherits from std::enable_shared_from_this< ExecutionStream >
Public Functions¶
| Name | |
|---|---|
| ExecutionStream(int stream_id =0, int device_id =0) | |
| ~ExecutionStream() Stop the worker, drain queued tasks, and join the thread. |
|
| ExecutionStream(const ExecutionStream & ) =delete | |
| ExecutionStream & | operator=(const ExecutionStream & ) =delete |
| int | StreamId() const Return the stream identifier. |
| int | DeviceId() const Return the owning device identifier. |
| void | RecordEvent(StreamEvent & event) Record an event capturing work queued so far. |
| void | WaitEvent(const StreamEvent & event) Make subsequent work wait for an event. |
| void | Synchronize() Block until all queued work finishes. |
| void | Submit(std::function< void()> task) Enqueue a task for serialized execution. |
| template <typename F > auto |
AsyncSubmit(F && task) |
| ExecutionStream & | DefaultStream(int device_id =0) Access the process-wide stream for a device. |
| std::shared_ptr< ExecutionStream > | Create(int device_id =0) Create a new heap-allocated stream for a device. |
Public Functions Documentation¶
function ExecutionStream¶
Parameters:
- stream_id Stream identifier.
- device_id Device the stream targets.
Start a stream and its dedicated worker thread.
function ~ExecutionStream¶
Stop the worker, drain queued tasks, and join the thread.
function ExecutionStream¶
function operator=¶
function StreamId¶
Return the stream identifier.
function DeviceId¶
Return the owning device identifier.
function RecordEvent¶
Record an event capturing work queued so far.
Parameters:
- event Event to mark complete.
Queue an event record on this stream.
function WaitEvent¶
Make subsequent work wait for an event.
Parameters:
- event Event to wait for.
Queue a wait on event so subsequent tasks run after it completes.
function Synchronize¶
Block until all queued work finishes.
Block until all queued and in-flight tasks finish.
function Submit¶
Enqueue a task for serialized execution.
Parameters:
- task Callable to run; must not be null.
Enqueue a task for asynchronous execution on the worker.
function AsyncSubmit¶
Parameters:
- task Callable to run on the stream.
Return: Future that yields the callable's result.
Enqueue a task and return a future yielding its result.
function DefaultStream¶
Access the process-wide stream for a device.
Parameters:
- device_id Device the stream targets.
Return: Reference to the device's default stream.
Get (creating on first use) the shared default stream for a device.
function Create¶
Create a new heap-allocated stream for a device.
Parameters:
- device_id Device the stream targets.
Return: Owning pointer to the new stream.
Create a new independent stream for a device.