Future Class Reference

Future Class Reference#

SDK qb Runtime Library: mobilint::Future Class Reference
SDK qb Runtime Library v0.29
MCS001-KR

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< float > > get (StatusCode &sc)
 Blocks until asynchronous inference completes and retrieves the output.

Friends

class FutureImpl

Detailed Description

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 41 of file future.h.

Member Function Documentation

◆ waitFor()

bool mobilint::Future::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()

std::vector< NDArray< float > > mobilint::Future::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<float> containing the inference output.

◆ FutureImpl

friend class FutureImpl
friend

Definition at line 83 of file future.h.


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