]> gitweb.factorcode.org Git - factor.git/commitdiff
fix stack effects for nanosseconds, update io backends for nanos
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 19 Nov 2009 10:51:47 +0000 (04:51 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 19 Nov 2009 10:51:47 +0000 (04:51 -0600)
basis/io/backend/unix/multiplexers/epoll/epoll.factor
basis/io/backend/unix/multiplexers/kqueue/kqueue.factor
basis/io/backend/unix/multiplexers/multiplexers.factor
basis/io/backend/unix/multiplexers/select/select.factor
basis/threads/threads-docs.factor
basis/threads/threads.factor
basis/unix/time/time.factor
core/bootstrap/primitives.factor

index b9c224c6294bb3d2c2f739dd9b2badb97e97c80f..3985729935dd95099828e546e33b94874a282fb3 100644 (file)
@@ -51,8 +51,8 @@ M: epoll-mx remove-output-callbacks ( fd mx -- seq )
         [ EPOLLOUT do-epoll-del ] [ call-next-method ] 2bi
     ] [ 2drop f ] if ;
 
-: wait-event ( mx us -- n )
-    [ [ fd>> ] [ events>> ] bi dup length ] [ 1000 /i ] bi*
+: wait-event ( mx nanos -- n )
+    [ [ fd>> ] [ events>> ] bi dup length ] [ 1000000 /i ] bi*
     epoll_wait multiplexer-error ;
 
 : handle-event ( event mx -- )
@@ -63,5 +63,5 @@ M: epoll-mx remove-output-callbacks ( fd mx -- seq )
 : handle-events ( mx n -- )
     [ dup events>> ] dip head-slice swap '[ _ handle-event ] each ;
 
-M: epoll-mx wait-for-events ( us mx -- )
+M: epoll-mx wait-for-events ( nanos mx -- )
     swap 60000000 or dupd wait-event handle-events ;
index c777e57f1db528649fa30fb949576323d35ff6c2..16d0338da532eb39f8e59129797353b2db545155 100644 (file)
@@ -73,6 +73,6 @@ M: kqueue-mx remove-output-callbacks ( fd mx -- seq )
     [ dup events>> ] dip head-slice
     [ handle-kevent ] with each ;
 
-M: kqueue-mx wait-for-events ( us mx -- )
+M: kqueue-mx wait-for-events ( nanos mx -- )
     swap dup [ make-timespec ] when
     dupd wait-kevent handle-kevents ;
index 73d8a603104061b7b7f81c36ae100ef59fc81ca1..ded028dda49e62a15bb61a66526f72ff7fde6319 100644 (file)
@@ -26,7 +26,7 @@ GENERIC: remove-output-callbacks ( fd mx -- callbacks )
 
 M: mx remove-output-callbacks writes>> delete-at* drop ;
 
-GENERIC: wait-for-events ( ms mx -- )
+GENERIC: wait-for-events ( nanos mx -- )
 
 : input-available ( fd mx -- )
     reads>> delete-at* drop [ resume ] each ;
index 8022ed34e223f899cb302486d63efa795b3e2368..f2d1a3a3b78c3cf7a22f5048c3a1e26591cb0741 100644 (file)
@@ -48,9 +48,9 @@ TUPLE: select-mx < mx read-fdset write-fdset ;
     [ write-fdset/tasks [ init-fdset ] keep ] tri
     f ;
 
-M:: select-mx wait-for-events ( us mx -- )
+M:: select-mx wait-for-events ( nanos mx -- )
     mx
-    [ init-fdsets us dup [ make-timeval ] when select multiplexer-error drop ]
+    [ init-fdsets nanos 1000 /i dup [ make-timeval ] when select multiplexer-error drop ]
     [ [ read-fdset/tasks ] keep [ input-available ] check-fdset ]
     [ [ write-fdset/tasks ] keep [ output-available ] check-fdset ]
     tri ;
index 2f205b0886924bad1a2590fd8e45f1c99517f941..995fc867e71c94f9160fa25f607187ff032d241e 100644 (file)
@@ -113,8 +113,8 @@ HELP: sleep-queue
 { $var-description "A " { $link min-heap } " storing the queue of sleeping threads." } ;
 
 HELP: sleep-time
-{ $values { "us/f" "a non-negative integer or " { $link f } } }
-{ $description "Outputs the time until the next sleeping thread is scheduled to wake up, which could be zero if there are threads in the run queue, or threads which need to wake up right now. If there are no runnable or sleeping threads, outputs " { $link f } "." } ;
+{ $values { "nanos/f" "a non-negative integer or " { $link f } } }
+{ $description "Returns the time until the next sleeping thread is scheduled to wake up, which could be zero if there are threads in the run queue, or threads which need to wake up right now. If there are no runnable or sleeping threads, returns " { $link f } "." } ;
 
 HELP: stop
 { $description "Stops the current thread. The thread may be started again from another thread using " { $link (spawn) } "." } ;
index 1330625db0cff42c41fb916d0c1eea8fc81d4539..af11d77f8458e89bc9090f99b5288c32317e2c17 100644 (file)
@@ -91,7 +91,7 @@ PRIVATE>
     f >>state
     check-registered 2array run-queue push-front ;
 
-: sleep-time ( -- us/f )
+: sleep-time ( -- nanos/f )
     {
         { [ run-queue deque-empty? not ] [ 0 ] }
         { [ sleep-queue heap-empty? ] [ f ] }
@@ -184,8 +184,7 @@ M: f sleep-until
 GENERIC: sleep ( dt -- )
 
 M: real sleep
-    >integer 1000 *
-    nano-count + sleep-until ;
+    >integer nano-count + sleep-until ;
 
 : interrupt ( thread -- )
     dup state>> [
index 4f5ac9930966cd4ee5acfebf1d58a285b79e928a..0a63965c20179fda605ac448a88183708c923ac9 100644 (file)
@@ -18,8 +18,8 @@ STRUCT: timespec
         swap >>usec
         swap >>sec ;
 
-: make-timespec ( us -- timespec )
-    1000000 /mod 1000 *
+: make-timespec ( nanos -- timespec )
+    1000000000 /mod
     timespec <struct>
         swap >>nsec
         swap >>sec ;
index 64e22ebabf4453ee12d068060c8f04feb51225c8..3dcd5969c9fa67532b88e4886945e57086909d4d 100644 (file)
@@ -495,7 +495,7 @@ tuple
     { "<tuple>" "classes.tuple.private" (( layout -- tuple )) }
     { "profiling" "tools.profiler.private" (( ? -- )) }
     { "become" "kernel.private" (( old new -- )) }
-    { "(sleep)" "threads.private" (( us -- )) }
+    { "(sleep)" "threads.private" (( nanos -- )) }
     { "<tuple-boa>" "classes.tuple.private" (( ... layout -- tuple )) }
     { "callstack>array" "kernel" (( callstack -- array )) }
     { "innermost-frame-executing" "kernel.private" (( callstack -- obj )) }