a iterator that was backed by a thread to pull data eagerly from a single producer into a bounded buffer the consumer can pull the data at its own rate
More...
|
| ThreadedIter (size_t max_capacity=8) |
| constructor More...
|
|
virtual | ~ThreadedIter (void) |
| destructor More...
|
|
void | Destroy (void) |
| destroy all the related resources this is equivalent to destructor, can be used to destroy the threaditer when user think it is appropriate, it is safe to call this multiple times More...
|
|
void | set_max_capacity (size_t max_capacity) |
| set maximum capacity of the queue More...
|
|
void | Init (std::shared_ptr< Producer > producer) |
| initialize the producer and start the thread can only be called once More...
|
|
void | Init (std::function< bool(DType **)> next, std::function< void()> beforefirst=NotImplemented) |
| initialize the producer and start the thread pass in two function(closure) of producer to represent the producer the beforefirst function is optional, and defaults to not implemented NOTE: the closure must remain valid until the ThreadedIter destructs More...
|
|
bool | Next (DType **out_dptr) |
| get the next data, this function is threadsafe More...
|
|
void | Recycle (DType **inout_dptr) |
| recycle the data cell, this function is threadsafe the threaditer can reuse the data cell for future data loading More...
|
|
void | ThrowExceptionIfSet (void) |
| Rethrows exception which is set by the producer. More...
|
|
void | ClearException (void) |
| clears exception_ptr, called from Init More...
|
|
virtual bool | Next (void) |
| adapt the iterator interface's Next NOTE: the call to this function is not threadsafe use the other Next instead More...
|
|
virtual const DType & | Value (void) const |
| adapt the iterator interface's Value NOTE: the call to this function is not threadsafe use the other Next instead More...
|
|
virtual void | BeforeFirst (void) |
| set the iterator before first location More...
|
|
virtual | ~DataIter (void) DMLC_THROW_EXCEPTION |
| destructor More...
|
|
template<typename DType>
class dmlc::ThreadedIter< DType >
a iterator that was backed by a thread to pull data eagerly from a single producer into a bounded buffer the consumer can pull the data at its own rate
NOTE: thread concurrency cost time, make sure to store big blob of data in DType
Usage example:
ThreadedIter<DType> iter;
iter.Init(&producer);
DType *dptr;
while (iter.Next(&dptr)) {
iter.Recycle(&dptr);
}
- Template Parameters
-
DType | the type of data blob we support |