Future< T > Class Template Reference

Future&lt; T &gt; Class Template Reference#

Runtime Library: mobilint::Future< T > Class Template Reference
Runtime Library v0.30
Mobilint SDK qb
mobilint::Future< T > Class Template Reference

Represents a future for retrieving the result of asynchronous inference. More...

#include <future.h>

Public Member Functions

 Future (const Future &other)=delete
Futureoperator= (const Future &other)=delete
 Future (Future &&other) noexcept
Futureoperator= (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

template<typename T>
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.

Definition at line 43 of file future.h.

Member Function Documentation

◆ waitFor()

template<typename T>
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]timeoutMaximum duration to wait, in milliseconds.
Returns
True if inference completed before the timeout, false otherwise.

◆ get()

template<typename T>
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]scA 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.

◆ FutureImpl< T >

template<typename T>
friend class FutureImpl< T >
friend

Definition at line 83 of file future.h.


The documentation for this class was generated from the following file: