콘텐츠로 이동

Future

#include <qbruntime/future.h>

template <typename T>
class mobilint::Future

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 functions

Member Description
Future ×3
operator= ×2
waitFor Waits for asynchronous inference to complete or until the timeout elapses.
get Blocks until asynchronous inference completes and retrieves the output.

Future

Future()
Future(const Future &other)=delete
Future(Future &&other) noexcept

operator=

Future & operator=(const Future &other)=delete
Future & operator=(Future &&other) noexcept

waitFor

bool 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

  • timeout [in] — Maximum duration to wait, in milliseconds.

Returns

True if inference completed before the timeout, false otherwise.

get

std::vector<NDArray<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

  • sc [out] — 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.