Mercurial > octave
comparison libinterp/corefcn/utils.cc @ 20923:58263bea2fdf
Unified "sleep" functions to "octave_sleep" in C++ and "pause" in Octave.
* doc/interpreter/system.txi: removed sleep and usleep from doc.
* libinterp/corefcn/sysdep.cc (pause): updated docstring.
* libinterp/corefcn/sysdep.cc (sleep): moved to deprecate sleep.m.
* libinterp/corefcn/sysdep.cc (usleep): moved to deprecate usleep.m.
* scripts/deprecated/sleep.m: moved here from sysdep.cc.
* scripts/deprecated/usleep.m: moved here from sysdep.cc.
* scripts/deprecated/module.mk: add sleep.m and usleep.m to build system.
* NEWS: deprecation news for sleep and usleep.
* libinterp/corefcn/data.cc: examples updated.
* libinterp/corefcn/syscalls.cc: examples updated.
* scripts/audio/@audioplayer/audioplayer.m: examples updated.
* scripts/audio/@audiorecorder/audiorecorder.m: examples updated.
* scripts/plot/util/ginput.m: examples updated.
* scripts/plot/util/private/__gnuplot_get_var__.m: use pause.
* scripts/plot/util/private/__gnuplot_ginput__.m: use pause.
* libinterp/corefcn/utils.cc (octave_sleep): Unified "sleep" functions here.
* libinterp/corefcn/utils.h: removed header cutils.h.
* libinterp/corefcn/graphics.cc (drawnow): use octave_sleep.
* libinterp/corefcn/graphics.cc (waitfor): use octave_sleep.
* libinterp/corefcn/toplev.cc (clean_up_and_exit): use octave_sleep.
* libinterp/corefcn/cutils.c: removed no longer needed code.
* libinterp/corefcn/cutils.h: removed no longer needed header.
* libinterp/corefcn/matherr.c: removed orphaned code.
* libinterp/corefcn/module.mk: removed cutils.h, cutils.c, and matherr.c from
build system.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Thu, 17 Dec 2015 16:04:13 +0100 |
parents | 1142cf6abc0d |
children | 667861ffffab |
comparison
equal
deleted
inserted
replaced
20922:49081851fddc | 20923:58263bea2fdf |
---|---|
1353 } | 1353 } |
1354 | 1354 |
1355 void | 1355 void |
1356 octave_sleep (double seconds) | 1356 octave_sleep (double seconds) |
1357 { | 1357 { |
1358 if (seconds > 0) | 1358 if (seconds <= 0) |
1359 { | 1359 return; |
1360 double t; | 1360 |
1361 | 1361 double fraction = std::modf (seconds, &seconds); |
1362 unsigned int usec | 1362 fraction = std::floor (fraction * 1000000000); // nanoseconds |
1363 = static_cast<unsigned int> (modf (seconds, &t) * 1000000); | 1363 |
1364 | 1364 time_t sec = ((seconds > std::numeric_limits<time_t>::max ()) |
1365 unsigned int sec | 1365 ? std::numeric_limits<time_t>::max () |
1366 = ((t > std::numeric_limits<unsigned int>::max ()) | 1366 : static_cast<time_t> (seconds)); |
1367 ? std::numeric_limits<unsigned int>::max () | 1367 |
1368 : static_cast<unsigned int> (t)); | 1368 // call GNULIB POSIX function |
1369 | 1369 struct timespec delay = { sec, static_cast<long> (fraction) }; |
1370 // Versions of these functions that accept unsigned int args are | 1370 struct timespec remaining; |
1371 // defined in cutils.c. | 1371 gnulib::nanosleep (&delay, &remaining); |
1372 octave_sleep (sec); | 1372 |
1373 octave_usleep (usec); | 1373 octave_quit (); |
1374 | |
1375 octave_quit (); | |
1376 } | |
1377 } | 1374 } |
1378 | 1375 |
1379 DEFUN (isindex, args, , | 1376 DEFUN (isindex, args, , |
1380 "-*- texinfo -*-\n\ | 1377 "-*- texinfo -*-\n\ |
1381 @deftypefn {} {} isindex (@var{ind})\n\ | 1378 @deftypefn {} {} isindex (@var{ind})\n\ |