Main Content

Background Processing

Run code in the background and run other code at the same time

When you run code in MATLAB®, you must wait for that code to finish running before you can run other code. The background pool enables you to run code in the background and run other code at the same time. For instance, you can create apps that remain responsive while performing calculations in the background.

Use parfeval with the background pool to run a function in the background. parfeval immediately returns a Future object that represents the function running in the background. To get results from the Future, call fetchOutputs.

Functions

expand all

parfevalRun function in background
backgroundPoolEnvironment for running code in the background (Since R2021b)
fetchOutputsRetrieve results from function running in the background
afterEachRun function after each function finishes running in the background
afterAllRun function after all functions finish running in the background
cancelStop function running in the background
cancelAllStop all functions running in the background (Since R2022a)
waitWait for futures to complete
fetchNextRetrieve next unread outputs from Future array
FutureFunction scheduled to run
sendSend data to DataQueue or PollableDataQueue
pollRetrieve data from PollableDataQueue
afterEachRun function after data is received on DataQueue
parallel.pool.DataQueueSend and automatically process data
parallel.pool.PollableDataQueueSend and manually retrieve data

Topics

Get Started with Background Processing

Applications