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

View File

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