Request function execution on parallel pool workers or MATLAB client
A Future
object represents a function to be executed on parallel
pool workers or the MATLAB® client.
There are several ways to create a Future
object:
Specify a function to be executed on a worker in a parallel pool using parfeval
. The parfeval
function creates a
FevalFuture
object to represent the function execution and hold the
results. To create multiple FevalFutures
, call parfeval
multiple times; for example, you can create a vector of
FevalFutures
in a for
-loop.
Specify a function to be executed on every worker in a parallel pool using parfevalOnAll
. The parfevalOnAll
function creates a
FevalOnAllFuture
object to represent the function execution and hold
the results.
Specify a function to be executed on the MATLAB client after all Future
objects complete using afterAll
.
The afterAll
function creates an AfterAllFuture
object to represent the function execution and hold the results.
Specify a function to be executed on the MATLAB client after each Future
object complete using afterEach
.
The afterEach
function creates an AfterEachFuture
object to represent the function execution and hold the results.
In summary, the following table describes the available types of future objects:
Future Object | Description |
---|---|
FevalFuture | Single parfeval Future instance |
FevalOnAllFuture | parfevalOnAll Future instance |
AfterAllFuture | afterAll Future instance |
AfterEachFuture | afterEach Future instance |
Future
objects are local objects and can be accessed only in the
MATLAB session that created it.
afterAll
| afterEach
| parallel.Pool
| parfeval
| parfevalOnAll