parent
77d9dc06a6
commit
dadaae59a1
|
|
@ -1,51 +1,55 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: io.backend kernel continuations namespaces sequences
|
USING: io.backend kernel continuations namespaces sequences
|
||||||
assocs hashtables sorting arrays threads boxes io.timeouts
|
assocs hashtables sorting arrays threads boxes io.timeouts
|
||||||
accessors concurrency.mailboxes ;
|
accessors concurrency.mailboxes ;
|
||||||
IN: io.monitors
|
IN: io.monitors
|
||||||
|
|
||||||
HOOK: init-monitors io-backend ( -- )
|
HOOK: init-monitors io-backend ( -- )
|
||||||
|
|
||||||
HOOK: dispose-monitors io-backend ( -- )
|
M: object init-monitors ;
|
||||||
|
|
||||||
: with-monitors ( quot -- )
|
HOOK: dispose-monitors io-backend ( -- )
|
||||||
[
|
|
||||||
init-monitors
|
M: object dispose-monitors ;
|
||||||
[ dispose-monitors ] [ ] cleanup
|
|
||||||
] with-scope ; inline
|
: with-monitors ( quot -- )
|
||||||
|
[
|
||||||
TUPLE: monitor < identity-tuple path queue timeout ;
|
init-monitors
|
||||||
|
[ dispose-monitors ] [ ] cleanup
|
||||||
M: monitor hashcode* path>> hashcode* ;
|
] with-scope ; inline
|
||||||
|
|
||||||
M: monitor timeout timeout>> ;
|
TUPLE: monitor < identity-tuple path queue timeout ;
|
||||||
|
|
||||||
M: monitor set-timeout (>>timeout) ;
|
M: monitor hashcode* path>> hashcode* ;
|
||||||
|
|
||||||
: construct-monitor ( path mailbox class -- monitor )
|
M: monitor timeout timeout>> ;
|
||||||
construct-empty
|
|
||||||
swap >>queue
|
M: monitor set-timeout (>>timeout) ;
|
||||||
swap >>path ; inline
|
|
||||||
|
: construct-monitor ( path mailbox class -- monitor )
|
||||||
: queue-change ( path changes monitor -- )
|
construct-empty
|
||||||
3dup and and
|
swap >>queue
|
||||||
[ [ 3array ] keep queue>> mailbox-put ] [ 3drop ] if ;
|
swap >>path ; inline
|
||||||
|
|
||||||
HOOK: (monitor) io-backend ( path recursive? mailbox -- monitor )
|
: queue-change ( path changes monitor -- )
|
||||||
|
3dup and and
|
||||||
: <monitor> ( path recursive? -- monitor )
|
[ [ 3array ] keep queue>> mailbox-put ] [ 3drop ] if ;
|
||||||
<mailbox> (monitor) ;
|
|
||||||
|
HOOK: (monitor) io-backend ( path recursive? mailbox -- monitor )
|
||||||
: next-change ( monitor -- path changed )
|
|
||||||
[ queue>> ] [ timeout ] bi mailbox-get-timeout first2 ;
|
: <monitor> ( path recursive? -- monitor )
|
||||||
|
<mailbox> (monitor) ;
|
||||||
SYMBOL: +add-file+
|
|
||||||
SYMBOL: +remove-file+
|
: next-change ( monitor -- path changed )
|
||||||
SYMBOL: +modify-file+
|
[ queue>> ] [ timeout ] bi mailbox-get-timeout first2 ;
|
||||||
SYMBOL: +rename-file-old+
|
|
||||||
SYMBOL: +rename-file-new+
|
SYMBOL: +add-file+
|
||||||
SYMBOL: +rename-file+
|
SYMBOL: +remove-file+
|
||||||
|
SYMBOL: +modify-file+
|
||||||
: with-monitor ( path recursive? quot -- )
|
SYMBOL: +rename-file-old+
|
||||||
>r <monitor> r> with-disposal ; inline
|
SYMBOL: +rename-file-new+
|
||||||
|
SYMBOL: +rename-file+
|
||||||
|
|
||||||
|
: with-monitor ( path recursive? quot -- )
|
||||||
|
>r <monitor> r> with-disposal ; inline
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,6 @@ M: bsd init-io ( -- )
|
||||||
[ mx get-global reads>> set-at ]
|
[ mx get-global reads>> set-at ]
|
||||||
[ mx get-global writes>> set-at ] 2bi ;
|
[ mx get-global writes>> set-at ] 2bi ;
|
||||||
|
|
||||||
M: bsd init-monitors ;
|
|
||||||
|
|
||||||
M: bsd dispose-monitors ;
|
|
||||||
|
|
||||||
M: bsd (monitor) ( path recursive? mailbox -- )
|
M: bsd (monitor) ( path recursive? mailbox -- )
|
||||||
swap [ "Recursive kqueue monitors not supported" throw ] when
|
swap [ "Recursive kqueue monitors not supported" throw ] when
|
||||||
<vnode-monitor> ;
|
<vnode-monitor> ;
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,6 @@ TUPLE: macosx-monitor < monitor handle ;
|
||||||
>r first { +modify-file+ } r> queue-change
|
>r first { +modify-file+ } r> queue-change
|
||||||
] curry each ;
|
] curry each ;
|
||||||
|
|
||||||
M: macosx init-monitors ;
|
|
||||||
|
|
||||||
M: macosx dispose-monitors ;
|
|
||||||
|
|
||||||
M:: macosx (monitor) ( path recursive? mailbox -- monitor )
|
M:: macosx (monitor) ( path recursive? mailbox -- monitor )
|
||||||
path mailbox macosx-monitor construct-monitor
|
path mailbox macosx-monitor construct-monitor
|
||||||
dup [ enqueue-notifications ] curry
|
dup [ enqueue-notifications ] curry
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ io.timeouts io.nonblocking io.windows io.windows.nt.backend
|
||||||
kernel libc math threads windows windows.kernel32 system
|
kernel libc math threads windows windows.kernel32 system
|
||||||
alien.c-types alien.arrays sequences combinators combinators.lib
|
alien.c-types alien.arrays sequences combinators combinators.lib
|
||||||
sequences.lib ascii splitting alien strings assocs namespaces
|
sequences.lib ascii splitting alien strings assocs namespaces
|
||||||
io.files.private ;
|
io.files.private accessors ;
|
||||||
IN: io.windows.nt.files
|
IN: io.windows.nt.files
|
||||||
|
|
||||||
M: winnt cwd
|
M: winnt cwd
|
||||||
|
|
@ -87,9 +87,9 @@ M: port port-flush
|
||||||
: finish-read ( overlapped port -- )
|
: finish-read ( overlapped port -- )
|
||||||
dup pending-error
|
dup pending-error
|
||||||
tuck get-overlapped-result dup zero? [
|
tuck get-overlapped-result dup zero? [
|
||||||
drop t swap set-port-eof?
|
drop t >>eof drop
|
||||||
] [
|
] [
|
||||||
dup pick n>buffer
|
dup pick buffer>> n>buffer
|
||||||
swap update-file-ptr
|
swap update-file-ptr
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ USING: alien alien.c-types libc destructors locals
|
||||||
kernel math assocs namespaces continuations sequences hashtables
|
kernel math assocs namespaces continuations sequences hashtables
|
||||||
sorting arrays combinators math.bitfields strings system
|
sorting arrays combinators math.bitfields strings system
|
||||||
io.windows io.windows.nt.backend io.monitors io.nonblocking
|
io.windows io.windows.nt.backend io.monitors io.nonblocking
|
||||||
io.buffers io.files io.timeouts io
|
io.buffers io.files io.timeouts io accessors threads
|
||||||
windows windows.kernel32 windows.types ;
|
windows windows.kernel32 windows.types ;
|
||||||
IN: io.windows.nt.monitors
|
IN: io.windows.nt.monitors
|
||||||
|
|
||||||
|
|
@ -21,7 +21,9 @@ IN: io.windows.nt.monitors
|
||||||
dup add-completion
|
dup add-completion
|
||||||
f <win32-file> ;
|
f <win32-file> ;
|
||||||
|
|
||||||
TUPLE: win32-monitor < monitor port recursive ;
|
TUPLE: win32-monitor-port < input-port recursive ;
|
||||||
|
|
||||||
|
TUPLE: win32-monitor < monitor port ;
|
||||||
|
|
||||||
: begin-reading-changes ( port -- overlapped )
|
: begin-reading-changes ( port -- overlapped )
|
||||||
{
|
{
|
||||||
|
|
@ -83,9 +85,11 @@ TUPLE: win32-monitor < monitor port recursive ;
|
||||||
M:: winnt (monitor) ( path recursive? mailbox -- monitor )
|
M:: winnt (monitor) ( path recursive? mailbox -- monitor )
|
||||||
[
|
[
|
||||||
path mailbox win32-monitor construct-monitor
|
path mailbox win32-monitor construct-monitor
|
||||||
path open-directory <buffered-port> >>port
|
path open-directory \ win32-monitor-port <buffered-port>
|
||||||
recursive? >>recursive
|
recursive? >>recursive
|
||||||
dup port>> [ fill-queue-thread ] curry spawn drop
|
>>port
|
||||||
|
dup [ fill-queue-thread ] curry
|
||||||
|
"Windows monitor thread" spawn drop
|
||||||
] with-destructors ;
|
] with-destructors ;
|
||||||
|
|
||||||
M: win32-monitor dispose
|
M: win32-monitor dispose
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ USING: alien alien.accessors alien.c-types byte-arrays
|
||||||
continuations destructors io.nonblocking io.timeouts io.sockets
|
continuations destructors io.nonblocking io.timeouts io.sockets
|
||||||
io.sockets.impl io namespaces io.streams.duplex io.windows
|
io.sockets.impl io namespaces io.streams.duplex io.windows
|
||||||
io.windows.nt.backend windows.winsock kernel libc math sequences
|
io.windows.nt.backend windows.winsock kernel libc math sequences
|
||||||
threads classes.tuple.lib system ;
|
threads classes.tuple.lib system accessors ;
|
||||||
IN: io.windows.nt.sockets
|
IN: io.windows.nt.sockets
|
||||||
|
|
||||||
: malloc-int ( object -- object )
|
: malloc-int ( object -- object )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue