|
OpenVDB 11.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. | |
| using | Notifier = std::function<void (Id, Status)> |
Public Member Functions | |
| Queue (Index32 capacity=DEFAULT_CAPACITY) | |
| Construct a queue with the given capacity. | |
| ~Queue () | |
| Block until all queued tasks complete (successfully or unsuccessfully). | |
| bool | empty () const |
Return true if the queue is empty. | |
| Index32 | size () const |
| Return the number of tasks currently in the queue. | |
| Index32 | capacity () const |
| Return the maximum number of tasks allowed in the queue. | |
| void | setCapacity (Index32) |
| Set the maximum number of tasks allowed in the queue. | |
| Index32 | timeout () const |
| Return the maximum number of seconds to wait to queue a task when the queue is full. | |
| void | setTimeout (Index32 seconds=DEFAULT_TIMEOUT) |
| Set the maximum number of seconds to wait to queue a task when the queue is full. | |
| Status | status (Id) const |
| Return the status of the task with the given ID. | |
| 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. | |
| void | removeNotifier (Id) |
| Deregister the notifier with the given ID. | |
| void | clearNotifiers () |
| Deregister all notifiers. | |
| Id | writeGrid (GridBase::ConstPtr grid, const Archive &archive, const MetaMap &fileMetadata=MetaMap()) |
| Queue a single grid for output to a file or stream. | |
| 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. | |
| 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()) | |
| static const Index32 | DEFAULT_TIMEOUT = 120 |
| Default maximum time in seconds to wait to queue a task when the queue is full (see setTimeout()) | |
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 |
|
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 |
| 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())