Template Class DataShuttle
Defined in File data_shuttle.h
Page Contents
Class Documentation
-
template<typename Job, typename Result>
class DataShuttle Encapsulates the full life cycle of DataLoader jobs.
When a new job is enqueued to the
DataShuttle
, a counter for in-flight jobs is bumped. This job is said to be “in-flight” until its result is popped. Worker threads dequeue jobs as soon as they are available. When a worker finishes a job, it enqueues the result. Only when the main thread dequeues a result is the count of in-flight jobs decremented. When the main thread attempts to dequeue a job but no jobs are in-flight, that means the epoch is complete andpop_result
returns an empty optional.Public Functions
-
inline void push_job(Job job)
Pushes a new job. Called by the main thread.
-
inline void push_result(Result result)
Pushes the result of a job. Called by worker threads.
-
inline Job pop_job()
Returns the next job, blocking until there is one available.
Called by worker threads.
-
inline std::optional<Result> pop_result(std::optional<std::chrono::milliseconds> timeout = std::nullopt)
Returns the result of a job, or nullopt if all jobs were exhausted.
Called by the main thread.
-
inline void push_job(Job job)