OpenVDB
12.0.0
|
Queue for asynchronous output of grids to files or streams. More...
#include <openvdb/io/Queue.h>
Public Types | |
enum | Status { UNKNOWN, PENDING, SUCCEEDED, FAILED } |
Status of a queued task. More... | |
using | Id = Index32 |
ID number of a queued task or of a registered notification callback. More... | |
using | Notifier = std::function< void(Id, Status)> |
Public Member Functions | |
Queue (Index32 capacity=DEFAULT_CAPACITY) | |
Construct a queue with the given capacity. More... | |
~Queue () | |
Block until all queued tasks complete (successfully or unsuccessfully). More... | |
bool | empty () const |
Return true if the queue is empty. More... | |
Index32 | size () const |
Return the number of tasks currently in the queue. More... | |
Index32 | capacity () const |
Return the maximum number of tasks allowed in the queue. More... | |
void | setCapacity (Index32) |
Set the maximum number of tasks allowed in the queue. More... | |
Index32 | timeout () const |
Return the maximum number of seconds to wait to queue a task when the queue is full. More... | |
void | setTimeout (Index32 seconds=DEFAULT_TIMEOUT) |
Set the maximum number of seconds to wait to queue a task when the queue is full. More... | |
Status | status (Id) const |
Return the status of the task with the given ID. More... | |
Id | addNotifier (Notifier) |
Register a function that will be called with a task's ID and status when that task completes, whether successfully or not. More... | |
void | removeNotifier (Id) |
Deregister the notifier with the given ID. More... | |
void | clearNotifiers () |
Deregister all notifiers. More... | |
Id | writeGrid (GridBase::ConstPtr grid, const Archive &archive, const MetaMap &fileMetadata=MetaMap()) |
Queue a single grid for output to a file or stream. More... | |
template<typename GridPtrContainer > | |
Id | write (const GridPtrContainer &grids, const Archive &archive, const MetaMap &fileMetadata=MetaMap()) |
Queue a container of grids for output to a file. More... | |
template<> | |
Queue::Id | write (const GridCPtrVec &grids, const Archive &archive, const MetaMap &metadata) |
Static Public Attributes | |
static const Index32 | DEFAULT_CAPACITY = 100 |
Default maximum queue length (see setCapacity()) More... | |
static const Index32 | DEFAULT_TIMEOUT = 120 |
Default maximum time in seconds to wait to queue a task when the queue is full (see setTimeout()) More... | |
Queue for asynchronous output of grids to files or streams.
enum Status |
|
explicit |
Construct a queue with the given capacity.
~Queue | ( | ) |
Block until all queued tasks complete (successfully or unsuccessfully).
Register a function that will be called with a task's ID and status when that task completes, whether successfully or not.
When multiple notifiers are registered, they are called in the order in which they were registered.
Index32 capacity | ( | ) | const |
Return the maximum number of tasks allowed in the queue.
Once the queue has reached its maximum size, adding a new task will block until an existing task has executed.
void clearNotifiers | ( | ) |
Deregister all notifiers.
bool empty | ( | ) | const |
Return true
if the queue is empty.
void removeNotifier | ( | Id | ) |
Deregister the notifier with the given ID.
void setCapacity | ( | Index32 | ) |
Set the maximum number of tasks allowed in the queue.
void setTimeout | ( | Index32 | seconds = DEFAULT_TIMEOUT | ) |
Set the maximum number of seconds to wait to queue a task when the queue is full.
Index32 size | ( | ) | const |
Return the number of tasks currently in the queue.
Return the status of the task with the given ID.
Index32 timeout | ( | ) | const |
Return the maximum number of seconds to wait to queue a task when the queue is full.
|
inline |
Queue a container of grids for output to a file.
grids | any iterable container of grid pointers (e.g., a GridPtrVec or GridPtrSet) |
archive | the io::File or io::Stream to which to output the grids |
fileMetadata | optional file-level metadata |
RuntimeError | if the task cannot be queued within the time limit (see setTimeout()) because the queue is full |
|
inline |
Id writeGrid | ( | GridBase::ConstPtr | grid, |
const Archive & | archive, | ||
const MetaMap & | fileMetadata = MetaMap() |
||
) |
Queue a single grid for output to a file or stream.
grid | the grid to be serialized |
archive | the io::File or io::Stream to which to output the grid |
fileMetadata | optional file-level metadata |
RuntimeError | if the task cannot be queued within the time limit (see setTimeout()) because the queue is full |
|
static |
Default maximum queue length (see setCapacity())
|
static |
Default maximum time in seconds to wait to queue a task when the queue is full (see setTimeout())