omni::extras::getOutArray

Defined in omni/extras/OutArrayUtils.h

template<typename T, typename GetCallable, typename FillCallable>
omni::core::Result omni::extras::getOutArray(GetCallable &&getFn, FillCallable &&fillFn, uint32_t stackCount = (4096 / sizeof(T)), uint32_t maxRetryCount = (UINT32_MAX - 1))

Retrieves an array of unknown size using getFn and passes it to fillFn.

This utility is useful for transferring a raw array from the ABI to a modern C++ container.

In order to avoid heap access, stackCount can be used to try to transfer the array from getFn to fillFn using temporary stack storage. stackCount is the number of T’s that should be temporarily allocated on the stack. If stackCount is inadequate, this function falls back to using the heap. Care should be taken to not set stackCount to a value that would cause a stack overflow.

The source array may be dynamically growing in another thread, in which case this method will try maxRetryCount times to allocate an array of the proper size and retrieve the values. If this method exceeds the retry count, omni::core::kResultTryAgain is returned.

Return values

omni::core::kResultSuccess – on success, an appropriate error code otherwise.