chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH][5] Make `sleep` suspend thread if scheduler is


From: Evan Hanson
Subject: [Chicken-hackers] [PATCH][5] Make `sleep` suspend thread if scheduler is loaded, process otherwise
Date: Fri, 10 Jun 2016 15:24:42 +1200

Hello,

Here's another bit of work from the roadmap: it makes the behaviour of
`sleep` more intuitive in the presence or absence of threads. See the
commit message for details.

There's an accompanying patch for srfi-18 (attached) which I'm happy to
apply if this looks good.

Cheers,

Evan
Index: release/5/srfi-18/trunk/srfi-18.scm
===================================================================
--- release/5/srfi-18/trunk/srfi-18.scm (revision 33384)
+++ release/5/srfi-18/trunk/srfi-18.scm (working copy)
@@ -277,15 +277,8 @@
     (##sys#add-to-ready-queue thread) ) )
 
 (define (thread-sleep! tm)
-  (define (sleep limit)
-    (##sys#call-with-current-continuation
-     (lambda (return)
-       (let ((ct ##sys#current-thread))
-        (##sys#setslot ct 1 (lambda () (return (##core#undefined))))
-        (##sys#thread-block-for-timeout! ct limit)
-        (##sys#schedule) ) ) ) )
   (unless tm (##sys#signal-hook #:type-error 'thread-sleep! "invalid timeout 
argument" tm))
-  (sleep (compute-time-limit tm 'thread-sleep!)) )
+  (##sys#thread-sleep! (compute-time-limit tm 'thread-sleep!)))
 
 
 ;;; Mutexes:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]