Microscopy Image Browser 2.91
MIB
Loading...
Searching...
No Matches
PoolWaitbar Class Reference

waitbar for parallel loops based on answer by Edric Ellis from https://se.mathworks.com/matlabcentral/answers/465911-parfor-waitbar-how-to-do-this-more-cleanly More...

Inheritance diagram for PoolWaitbar:
Collaboration diagram for PoolWaitbar:

Public Member Functions

 PoolWaitbar (N, message, existingHandle, WindowName, parentHandle)
 Constructor Parameters: N: number of iterations of the waitbar message: message to display existingHandle: a handle to existing standard waitbar figure WindowName: title of the figure window parentHandle: optional, a handle to the parent window, when it is provided and if it is done with appdesigner, uiprogressdlg function is used instead of waitbar.
 
function  updateMaxNumberOfIterations (N)
 update the max value of the waitbar slider
 
function  increaseMaxNumberOfIterations (N)
 increase maximal number of iterations by N
 
function res = getCancelState ()
 return state (true/false) of the cancel button only for uiprogressdlg
 
function count = getCurrentIteration ()
 return the current iteration
 
function result = getMaxNumberOfIterations ()
 get number of iterations
 
function  updateText (newText)
 update text of the waitbar
 
function  setCurrentIteration (count)
 set the current iteration of the poolwait bar to value N
 
function  setIncrement (increment)
 set a new increment value
 
function  increment ()
 
function  delete ()
 
function  deletePoolWaitbar (keepWaitbar)
 alternative way to delete PoolWaitbar
 
function wb = getWaitbarHandle ()
 return handle of the waitbar window, to be used before deleting PoolWaitbar to keep the waitbar window open
 

Additional Inherited Members

- Public Attributes inherited from handle
 addlistener
 Creates a listener for the specified event and assigns a callback function to execute when the event occurs.
 
 notify
 Broadcast a notice that a specific event is occurring on a specified handle object or array of handle objects.
 
 delete
 Handle object destructor method that is called when the object's lifecycle ends.
 
 disp
 Handle object disp method which is called by the display method. See the MATLAB disp function.
 
 display
 Handle object display method called when MATLAB software interprets an expression returning a handle object that is not terminated by a semicolon. See the MATLAB display function.
 
 findobj
 Finds objects matching the specified conditions from the input array of handle objects.
 
 findprop
 Returns a meta.property objects associated with the specified property name.
 
 fields
 Returns a cell array of string containing the names of public properties.
 
 fieldnames
 Returns a cell array of string containing the names of public properties. See the MATLAB fieldnames function.
 
 isvalid
 Returns a logical array in which elements are true if the corresponding elements in the input array are valid handles. This method is Sealed so you cannot override it in a handle subclass.
 
 eq
 Relational functions example. See details for more information.
 
 transpose
 Transposes the elements of the handle object array.
 
 permute
 Rearranges the dimensions of the handle object array. See the MATLAB permute function.
 
 reshape
 hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape function.
 
 sort
 ort the handle objects in any array in ascending or descending order.
 

Detailed Description

waitbar for parallel loops based on answer by Edric Ellis from https://se.mathworks.com/matlabcentral/answers/465911-parfor-waitbar-how-to-do-this-more-cleanly

Examples of use pwb = PoolWaitbar(100, Example); parfor ii = 1:20 % parfor (ii=1:20, obj.mibModel.cpuParallelLimit) pwb.increment(); end spmd for ii = 21:40 if labindex == 1 pwb.increment(); end end end for ii = 41:100 parfeval(@() increment(pwb), 0); end

% reuse exiting waitbar wb = waitbar(0.5, my waitbar); % create a standard waitbar n = 200; A = 500; a = zeros(n); pwb = PoolWaitbar(n, sprintf(Please wait...), wb); % create PoolWaitbar using existing waitbar window parfor i = 1:n % parfor (i=1:n, obj.mibModel.cpuParallelLimit) a(i) = max(abs(eig(rand(A)))); pwb.increment(); end keepWaitbar = 1; pwb.deletePoolWaitbar(keepWaitbar); % delete pw, while keeping wb

% Add with a title for the figure pwb = PoolWaitbar(n, sprintf(Please wait...), wb, My waitbar); pwb.setIncrement(10); % set increment step to 10, whenever needed pwb.updateText(New text); % update text % pwb.updateMaxNumberOfIterations(100); % increase number of iterations to 100 parfor i = 1:n % parfor (i=1:n, obj.mibModel.cpuParallelLimit) pwb.increment();
end

Constructor & Destructor Documentation

◆ PoolWaitbar()

PoolWaitbar.PoolWaitbar ( N,
message,
existingHandle,
WindowName,
parentHandle )

Constructor Parameters: N: number of iterations of the waitbar message: message to display existingHandle: a handle to existing standard waitbar figure WindowName: title of the figure window parentHandle: optional, a handle to the parent window, when it is provided and if it is done with appdesigner, uiprogressdlg function is used instead of waitbar.

Required fields of existingHandle:

Member Function Documentation

◆ delete()

function PoolWaitbar.delete ( )

◆ deletePoolWaitbar()

function PoolWaitbar.deletePoolWaitbar ( keepWaitbar)

alternative way to delete PoolWaitbar

Parameters
keepWaitbarlogical switch, when 1 - keeps instance of the waitbar obj.ClientHandle, otherwise deletes it

◆ getCancelState()

function res = PoolWaitbar.getCancelState ( )

return state (true/false) of the cancel button only for uiprogressdlg

◆ getCurrentIteration()

function count = PoolWaitbar.getCurrentIteration ( )

return the current iteration

◆ getMaxNumberOfIterations()

function result = PoolWaitbar.getMaxNumberOfIterations ( )

get number of iterations

◆ getWaitbarHandle()

function wb = PoolWaitbar.getWaitbarHandle ( )

return handle of the waitbar window, to be used before deleting PoolWaitbar to keep the waitbar window open

◆ increaseMaxNumberOfIterations()

function PoolWaitbar.increaseMaxNumberOfIterations ( N)

increase maximal number of iterations by N

◆ increment()

function PoolWaitbar.increment ( )

Referenced by setIncrement().

Here is the caller graph for this function:

◆ setCurrentIteration()

function PoolWaitbar.setCurrentIteration ( count)

set the current iteration of the poolwait bar to value N

◆ setIncrement()

function PoolWaitbar.setIncrement ( increment)

set a new increment value

References increment().

Here is the call graph for this function:

◆ updateMaxNumberOfIterations()

function PoolWaitbar.updateMaxNumberOfIterations ( N)

update the max value of the waitbar slider

◆ updateText()

function PoolWaitbar.updateText ( newText)

update text of the waitbar


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