sleep binding

Bug #210678 reported by rd
2
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Fix Committed
Wishlist
Abdulaziz Ghuloum

Bug Description

this is a feature request.
a way to pause the runtime would be very useful!
attached is a binding to the posix nanosleep function that could perhaps be a starting point?
regards,
rohan

=== modified file 'scheme/ikarus.time-and-date.ss'
--- scheme/ikarus.time-and-date.ss 2008-01-29 05:34:34 +0000
+++ scheme/ikarus.time-and-date.ss 2008-04-02 07:31:38 +0000
@@ -16,10 +16,12 @@

 (library (ikarus system time-and-date)
   (export current-time time? time-second time-nanosecond
- time-gmt-offset)
+ time-gmt-offset
+ nanosleep)
   (import
     (except (ikarus) time current-time time? time-second
- time-nanosecond time-gmt-offset))
+ time-nanosecond time-gmt-offset
+ nanosleep))

   (define-struct time (msecs secs usecs))
                   ;;; mega/seconds/micros
@@ -42,5 +44,9 @@
     (if (time? x)
         (foreign-call "ikrt_gmt_offset" x)
         (die 'time-gmt-offset "not a time" x)))
+
+ (define (nanosleep s ns)
+ (foreign-call "ikrt_nanosleep" s ns))
+
   )

=== modified file 'scheme/makefile.ss'
--- scheme/makefile.ss 2008-03-23 09:02:12 +0000
+++ scheme/makefile.ss 2008-04-02 07:32:21 +0000
@@ -382,6 +382,7 @@
     [time-second i]
     [time-gmt-offset i]
     [time-nanosecond i]
+ [nanosleep i]
     [command-line-arguments i]
     [set-rtd-printer! i]
     [make-record-type i]
=== modified file 'src/ikarus-runtime.c'
--- src/ikarus-runtime.c 2008-03-16 01:06:47 +0000
+++ src/ikarus-runtime.c 2008-04-02 07:29:59 +0000
@@ -877,6 +877,16 @@
   */
 }

+ikptr
+ikrt_nanosleep(ikptr s, ikptr ns) {
+ struct timespec ts;
+ int err;
+ ts.tv_sec = (time_t)unfix(s);
+ ts.tv_nsec = (long)unfix(ns);
+ err = nanosleep(&ts, NULL);
+ return (fix(err));
+}
+
 ikptr
 ikrt_fork(){
   int pid = fork();

Related branches

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Will do.

Changed in ikarus:
assignee: nobody → aghuloum
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Added in revision 1445.
Example:

> (time (nanosleep 3 135000000))
running stats for (nanosleep 3 135000000):
    no collections
    0 ms elapsed cpu time, including 0 ms collecting
    3135 ms elapsed real time, including 0 ms collecting
    0 bytes allocated

Changed in ikarus:
status: Confirmed → Fix Committed
Changed in ikarus:
milestone: none → 0.0.4
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.