diff options
author | Jean Boussier <[email protected]> | 2022-07-26 17:40:00 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2022-08-02 11:04:28 +0200 |
commit | e3aabe93aae87a60ba7b8f1a0fd590534647e352 (patch) | |
tree | 3f5c15b61c9914c7e1a34ad56d042dcf70024f75 /hrtime.h | |
parent | ec3f59309e3f08339c4c76a6881901580801d6cd (diff) |
Implement Queue#pop(timeout: sec)
[Feature #18774]
As well as `SizedQueue#pop(timeout: sec)`
If both `non_block=true` and `timeout:` are supplied, ArgumentError
is raised.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6185
Diffstat (limited to 'hrtime.h')
-rw-r--r-- | hrtime.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -36,6 +36,7 @@ #define RB_HRTIME_PER_MSEC (RB_HRTIME_PER_USEC * (rb_hrtime_t)1000) #define RB_HRTIME_PER_SEC (RB_HRTIME_PER_MSEC * (rb_hrtime_t)1000) #define RB_HRTIME_MAX UINT64_MAX +#define RB_HRTIME_MIN ((rb_hrtime_t)0) /* * Lets try to support time travelers. Lets assume anybody with a time machine @@ -91,6 +92,15 @@ rb_hrtime_add(rb_hrtime_t a, rb_hrtime_t b) return c; } +static inline rb_hrtime_t +rb_hrtime_sub(rb_hrtime_t a, rb_hrtime_t b) +{ + if (a < b) { + return RB_HRTIME_MIN; + } + return a - b; +} + /* * convert a timeval struct to rb_hrtime_t, clamping at RB_HRTIME_MAX */ |