Main Content

cancelAll

Stop all functions running in the background

    Description

    example

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

    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: [0x0 parallel.FevalFuture]
           RunningFutures: [1x1 parallel.FevalFuture]
    
    

    Use cancelAll to stop all Futures in FevalQueue.

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

    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