Future< T > Class Template Reference#
|
Runtime Library v0.30
Mobilint SDK qb
|
Represents a future for retrieving the result of asynchronous inference. More...
#include <future.h>
Public Member Functions | |
| Future (const Future &other)=delete | |
| Future & | operator= (const Future &other)=delete |
| Future (Future &&other) noexcept | |
| Future & | operator= (Future &&other) noexcept |
| bool | waitFor (int64_t timeout_ms) |
| Waits for asynchronous inference to complete or until the timeout elapses. | |
| std::vector< NDArray< T > > | get (StatusCode &sc) |
| Blocks until asynchronous inference completes and retrieves the output. | |
Friends | |
| class | FutureImpl< T > |
Detailed Description
class mobilint::Future< T >
Represents a future for retrieving the result of asynchronous inference.
This class provides a mechanism similar to std::future, allowing access to the result of an asynchronous inference operation initiated via Model::inferAsync or Model::inferAsyncCHW.
The Future object enables the caller to:
- Wait for the inference to complete (waitFor)
- Block until completion and retrieve the output (get)
Like std::future, this object can be moved but cannot be copied. It is associated with a unique asynchronous result. Once the output is retrieved via get, the Future becomes invalid and should not be reused.
Member Function Documentation
◆ waitFor()
| bool mobilint::Future< T >::waitFor | ( | int64_t | timeout_ms | ) |
Waits for asynchronous inference to complete or until the timeout elapses.
- Note
- This method is safe to call multiple times. Calling it with a timeout of zero (i.e., waitFor(0)) performs a non-blocking check to see whether asynchronous inference has already completed.
- Parameters
-
[in] timeout Maximum duration to wait, in milliseconds.
- Returns
- True if inference completed before the timeout, false otherwise.
◆ get()
| std::vector< NDArray< T > > mobilint::Future< T >::get | ( | StatusCode & | sc | ) |
Blocks until asynchronous inference completes and retrieves the output.
- Note
- This method should be called only once per Future. If called again, the return value will be invalid, and the status code will be set to StatusCode::Future_NotValid.
- Parameters
-
[out] sc A reference to a status code that will be updated to indicate whether the asynchronous inference completed successfully or if an error occurred.
- Returns
- A vector of NDArray<T> containing the inference output.
Friends And Related Symbol Documentation
◆ FutureImpl< T >
|
friend |
The documentation for this class was generated from the following file:
Generated by