1 //------------------------------------------------------------------------------
2 // gb_flush: flush mexPrintf output to MATLAB Command Window
3 //------------------------------------------------------------------------------
4
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: GPL-3.0-or-later
7
8 //------------------------------------------------------------------------------
9
10 // When GraphBLAS is under development, it is essential that output from
11 // mexPrintf be flushed to the MATLAB Command Window as soon as possible. This
12 // function ensures that this is done. The function is also used in
13 // production, when a MATLAB function wishes to display the contents of a GrB
14 // object, via disp or display. This ensures that all output from GraphBLAS is
15 // immediately visible in the MATLAB Command Window.
16
17 // https://www.mathworks.com/matlabcentral/answers/255615-why-are-mex-file-output-messages-using-mexprintf-mexevalstring-drawnow-not-printed-immediatel
18
19 // gb_flush ( ) returns 0 if successful, or any nonzero value on failure. This
20 // matches the behavior of the ANSI C fflush.
21
22 #include "gb_matlab.h"
23
gb_flush(void)24 int gb_flush ( void ) // flush mexPrintf output to MATLAB Command Window
25 {
26 // 'drawnow' is slow when logging in remotely: disable it.
27 // return (mexEvalString ("drawnow ; pause (1e-8) ;")) ;
28 return (mexEvalString ("pause (1e-8) ;")) ;
29 }
30
31