Monitors tweak

db4
Slava Pestov 2008-02-04 23:30:49 -06:00
parent 659b6d8f3c
commit 87887a1165
2 changed files with 10 additions and 16 deletions

View File

@ -25,8 +25,6 @@ TUPLE: inotify watches ;
: wd>monitor ( wd -- monitor ) watches at ; : wd>monitor ( wd -- monitor ) watches at ;
: wd>path ( wd -- path ) wd>monitor linux-monitor-path ;
: <inotify> ( -- port ) : <inotify> ( -- port )
H{ } clone H{ } clone
inotify_init dup io-error inotify <buffered-port> inotify_init dup io-error inotify <buffered-port>
@ -89,12 +87,8 @@ M: linux-monitor dispose ( monitor -- )
] { } make ; ] { } make ;
: parse-file-notify ( buffer -- changed path ) : parse-file-notify ( buffer -- changed path )
{ { inotify-event-name inotify-event-mask } get-slots
inotify-event-wd parse-action swap alien>char-string ;
inotify-event-name
inotify-event-mask
} get-slots
parse-action -rot alien>char-string >r wd>path r> path+ ;
: events-exhausted? ( i buffer -- ? ) : events-exhausted? ( i buffer -- ? )
buffer-fill >= ; buffer-fill >= ;

View File

@ -65,20 +65,20 @@ M: windows-nt-io <monitor> ( path recursive? -- monitor )
{ [ t ] [ +modify-file+ ] } { [ t ] [ +modify-file+ ] }
} cond nip ; } cond nip ;
: parse-file-notify ( directory buffer -- changed path ) : parse-file-notify ( buffer -- changed path )
{ {
FILE_NOTIFY_INFORMATION-FileName FILE_NOTIFY_INFORMATION-FileName
FILE_NOTIFY_INFORMATION-FileNameLength FILE_NOTIFY_INFORMATION-FileNameLength
FILE_NOTIFY_INFORMATION-Action FILE_NOTIFY_INFORMATION-Action
} get-slots parse-action 1array -rot } get-slots parse-action 1array swap
memory>u16-string path+ ; memory>u16-string ;
: (changed-files) ( directory buffer -- ) : (changed-files) ( buffer -- )
2dup parse-file-notify changed-file dup parse-file-notify changed-file
dup FILE_NOTIFY_INFORMATION-NextEntryOffset dup zero? dup FILE_NOTIFY_INFORMATION-NextEntryOffset dup zero?
[ 3drop ] [ swap <displaced-alien> (changed-files) ] if ; [ 2drop ] [ swap <displaced-alien> (changed-files) ] if ;
M: windows-nt-io fill-queue ( monitor -- ) M: windows-nt-io fill-queue ( monitor -- )
dup win32-monitor-path over buffer-ptr pick read-changes dup buffer-ptr over read-changes
[ zero? [ 2drop ] [ (changed-files) ] if ] H{ } make-assoc [ zero? [ drop ] [ (changed-files) ] if ] H{ } make-assoc
swap set-monitor-queue ; swap set-monitor-queue ;