Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(98)

Delta Between Two Patch Sets: Modules/timemodule.c

Issue 22043: Use a monotonic clock to compute timeouts
Left Patch Set: Created 3 years ago
Right Patch Set: Created 3 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Modules/socketmodule.c ('k') | Python/pytime.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* Time module */ 1 /* Time module */
2 2
3 #include "Python.h" 3 #include "Python.h"
4 4
5 #include <ctype.h> 5 #include <ctype.h>
6 6
7 #ifdef HAVE_SYS_TIMES_H 7 #ifdef HAVE_SYS_TIMES_H
8 #include <sys/times.h> 8 #include <sys/times.h>
9 #endif 9 #endif
10 10
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 #endif /* HAVE_WORKING_TZSET */ 896 #endif /* HAVE_WORKING_TZSET */
897 897
898 static PyObject * 898 static PyObject *
899 pymonotonic(_Py_clock_info_t *info) 899 pymonotonic(_Py_clock_info_t *info)
900 { 900 {
901 _PyTime_timeval tv; 901 _PyTime_timeval tv;
902 if (_PyTime_monotonic_info(&tv, info) < 0) { 902 if (_PyTime_monotonic_info(&tv, info) < 0) {
903 assert(info != NULL); 903 assert(info != NULL);
904 return NULL; 904 return NULL;
905 } 905 }
906 return PyFloat_FromDouble((double)tv.tv_sec + tv.tv_usec * 1e-6); 906 return PyFloat_FromDouble((double)tv.tv_sec + tv.tv_usec * 1e-6);
AntoinePitrou 2014/08/31 02:24:18 So the nanosecond resolution is being lost?
haypo 2014/08/31 15:02:33 I'm not sure that we really supported nanosecond r
907 } 907 }
908 908
909 static PyObject * 909 static PyObject *
910 time_monotonic(PyObject *self, PyObject *unused) 910 time_monotonic(PyObject *self, PyObject *unused)
911 { 911 {
912 return pymonotonic(NULL); 912 return pymonotonic(NULL);
913 } 913 }
914 914
915 PyDoc_STRVAR(monotonic_doc, 915 PyDoc_STRVAR(monotonic_doc,
916 "monotonic() -> float\n\ 916 "monotonic() -> float\n\
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 } 1470 }
1471 #else 1471 #else
1472 /* XXX Can't interrupt this sleep */ 1472 /* XXX Can't interrupt this sleep */
1473 Py_BEGIN_ALLOW_THREADS 1473 Py_BEGIN_ALLOW_THREADS
1474 sleep((int)secs); 1474 sleep((int)secs);
1475 Py_END_ALLOW_THREADS 1475 Py_END_ALLOW_THREADS
1476 #endif 1476 #endif
1477 1477
1478 return 0; 1478 return 0;
1479 } 1479 }
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7