[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 13/58: srfi-18: 'thread-sleep!' timeout-as-a-number is r
From: |
Andy Wingo |
Subject: |
[Guile-commits] 13/58: srfi-18: 'thread-sleep!' timeout-as-a-number is relative. |
Date: |
Tue, 7 Aug 2018 06:58:30 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit 898d97d440f3d19b27e1f815fd4d009f24a36433
Author: Ludovic Courtès <address@hidden>
Date: Fri Feb 16 15:17:37 2018 +0100
srfi-18: 'thread-sleep!' timeout-as-a-number is relative.
This is a followup to <https://bugs.gnu.org/29704>.
* module/srfi/srfi-18.scm (thread-sleep!): When TIMEOUT is a number,
keep it as-is.
* test-suite/tests/srfi-18.test ("thread sleep with number"): Pass 0 as
the timeout.
("thread sleeps fractions of a second"): Pass 0.5 as the timeout.
---
module/srfi/srfi-18.scm | 6 +++---
test-suite/tests/srfi-18.test | 5 ++---
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/module/srfi/srfi-18.scm b/module/srfi/srfi-18.scm
index 6d6596f..7177e06 100644
--- a/module/srfi/srfi-18.scm
+++ b/module/srfi/srfi-18.scm
@@ -235,9 +235,9 @@ object (absolute point in time), or #f."
(define (thread-yield!) (threads:yield) *unspecified*)
(define (thread-sleep! timeout)
- (let* ((ct (time->seconds (current-time)))
- (t (cond ((time? timeout) (- (time->seconds timeout) ct))
- ((number? timeout) (- timeout ct))
+ (let* ((t (cond ((time? timeout) (- (time->seconds timeout)
+ (time->seconds (current-time))))
+ ((number? timeout) timeout)
(else (scm-error 'wrong-type-arg "thread-sleep!"
"Wrong type argument: ~S"
(list timeout)
diff --git a/test-suite/tests/srfi-18.test b/test-suite/tests/srfi-18.test
index fc36dab..e547339 100644
--- a/test-suite/tests/srfi-18.test
+++ b/test-suite/tests/srfi-18.test
@@ -94,13 +94,12 @@
(unspecified? (thread-sleep! future-time))))
(pass-if "thread sleep with number"
- (let ((old-secs (car (current-time))))
- (unspecified? (thread-sleep! (+ (time->seconds (current-time)))))))
+ (unspecified? (thread-sleep! 0)))
(pass-if "thread sleeps fractions of a second"
(let* ((current (time->seconds (current-time)))
(future (+ current 0.5)))
- (thread-sleep! future)
+ (thread-sleep! 0.5)
(>= (time->seconds (current-time)) future)))
(pass-if "thread does not sleep on past time"
- [Guile-commits] branch lightning updated (0a01963 -> 0d00164), Andy Wingo, 2018/08/07
- [Guile-commits] 02/58: doc: Update LALR URL., Andy Wingo, 2018/08/07
- [Guile-commits] 06/58: Make sure the return value of 'scm_crypt' is always initialized., Andy Wingo, 2018/08/07
- [Guile-commits] 03/58: Fix 'crypt' deadlock upon error., Andy Wingo, 2018/08/07
- [Guile-commits] 01/58: Update NEWS for 2.2.3, Andy Wingo, 2018/08/07
- [Guile-commits] 07/58: No tabs in C code., Andy Wingo, 2018/08/07
- [Guile-commits] 04/58: 'load-thunk-from-memory' reports the correct error., Andy Wingo, 2018/08/07
- [Guile-commits] 13/58: srfi-18: 'thread-sleep!' timeout-as-a-number is relative.,
Andy Wingo <=
- [Guile-commits] 18/58: Fix typo in comment within numbers.c, Andy Wingo, 2018/08/07
- [Guile-commits] 08/58: Revert "Honor '%fresh-auto-compile'.", Andy Wingo, 2018/08/07
- [Guile-commits] 15/58: Fix eta-conversion edge cases in peval., Andy Wingo, 2018/08/07
- [Guile-commits] 17/58: Fix minor typo in the PEG documentation., Andy Wingo, 2018/08/07
- [Guile-commits] 20/58: Avoid inexact arithmetic in the type inferrer for 'sqrt'., Andy Wingo, 2018/08/07
- [Guile-commits] 16/58: Fix a few typos in the manual., Andy Wingo, 2018/08/07
- [Guile-commits] 05/58: compile: Load language modules upfront., Andy Wingo, 2018/08/07
- [Guile-commits] 11/58: doc: Fix typo about SRFI-4 syntax., Andy Wingo, 2018/08/07
- [Guile-commits] 09/58: 'select' returns empty sets upon EINTR and EAGAIN., Andy Wingo, 2018/08/07
- [Guile-commits] 14/58: Recognize RISC-V compilation targets., Andy Wingo, 2018/08/07