Merge branch 'master' of git://factorcode.org/git/factor

db4
Doug Coleman 2008-02-15 21:15:16 -06:00
commit e8c5187088
2 changed files with 17 additions and 5 deletions
extra
io/unix/select
tools/profiler

View File

@ -17,14 +17,18 @@ TUPLE: select-mx read-fdset write-fdset ;
FD_SETSIZE 8 * <bit-array> over set-select-mx-read-fdset
FD_SETSIZE 8 * <bit-array> over set-select-mx-write-fdset ;
: clear-nth ( n seq -- ? )
[ nth ] 2keep f -rot set-nth ;
: handle-fd ( fd task fdset mx -- )
roll munge rot nth [ swap handle-io-task ] [ 2drop ] if ;
roll munge rot clear-nth
[ swap handle-io-task ] [ 2drop ] if ;
: handle-fdset ( tasks fdset mx -- )
[ handle-fd ] 2curry assoc-each ;
: init-fdset ( tasks fdset -- )
dup clear-bits
! dup clear-bits
[ >r drop t swap munge r> set-nth ] curry assoc-each ;
: read-fdset/tasks
@ -33,13 +37,19 @@ TUPLE: select-mx read-fdset write-fdset ;
: write-fdset/tasks
{ mx-writes select-mx-write-fdset } get-slots ;
: init-fdsets ( mx -- read write except )
: max-fd dup assoc-empty? [ drop 0 ] [ keys supremum ] if ;
: num-fds ( mx -- n )
dup mx-reads max-fd swap mx-writes max-fd max 1+ ;
: init-fdsets ( mx -- nfds read write except )
[ num-fds ] keep
[ read-fdset/tasks tuck init-fdset ] keep
write-fdset/tasks tuck init-fdset
f ;
M: select-mx wait-for-events ( ms mx -- )
swap >r FD_SETSIZE over init-fdsets r> make-timeval
swap >r dup init-fdsets r> make-timeval
select multiplexer-error
dup read-fdset/tasks pick handle-fdset
dup write-fdset/tasks rot handle-fdset ;

View File

@ -59,5 +59,7 @@ M: string (profile.)
: vocabs-profile. ( -- )
"Call counts for all vocabularies:" print
vocabs [
dup words [ profile-counter ] map sum
dup words
[ "predicating" word-prop not ] subset
[ profile-counter ] map sum
] { } map>assoc counters. ;