Main Content

cancelAll

Stop all functions running in the background

Since R2022a

    Description

    cancelAll(p.FevalQueue) stops all queued or running elements of the background pool.

    For more information about using cancelAll to cancel all queued or running elements on a parallel pool, see cancelAll (Parallel Computing Toolbox).

    example

    Examples

    collapse all

    Create a background pool. Use parfeval to run pause(Inf) without retrieving any outputs.

    pool = backgroundPool;
    f = parfeval(pool,@pause,0,Inf);

    Check the status of functions queued and running in the pool.

    pool.FevalQueue
    ans = 
     FevalQueue with properties: 
    
            QueuedFutures: [1x1 parallel.FevalFuture]
           RunningFutures: [0x0 parallel.Future]
    
    

    Use cancelAll to stop all Futures in FevalQueue.

    cancelAll(pool.FevalQueue)
    pool.FevalQueue
    ans = 
     FevalQueue with properties: 
    
            QueuedFutures: [0x0 parallel.Future]
           RunningFutures: [0x0 parallel.Future]
    
    

    Input Arguments

    collapse all

    Queue of FevalFuture objects to run on the background pool, specified as an FevalFuture scalar and FevalFuture array.

    Version History

    Introduced in R2022a