function flushAllHandlers
% Flush all handlers.
% As a workaround for g1395903, each message is not flushed immediately 
% when they are published on Macs. Instead they are flushed when the 
% buffer is full. This method will explicitly flush all currently published
% messages.

% Copyright 2016-2020 The MathWorks, Inc.

try
    logger = com.mathworks.toolbox.parallel.pctutil.logging.RootLog.LOG;
    handlers = logger.getHandlers();
    for i = 1:numel(handlers)
        handlers(i).flush();
    end
catch e %#ok<NASGU> Let no exceptions escape during logging.
end
end
