]> gitweb.factorcode.org Git - factor.git/blob - basis/io/unix/macosx/monitors/monitors.factor
Create basis vocab root
[factor.git] / basis / io / unix / macosx / monitors / monitors.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io.backend io.monitors
4 core-foundation.fsevents continuations kernel sequences
5 namespaces arrays system locals accessors destructors ;
6 IN: io.unix.macosx.monitors
7
8 TUPLE: macosx-monitor < monitor handle ;
9
10 : enqueue-notifications ( triples monitor -- )
11     [
12         >r first { +modify-file+ } r> queue-change
13     ] curry each ;
14
15 M:: macosx (monitor) ( path recursive? mailbox -- monitor )
16     [let | path [ path normalize-path ] |
17         path mailbox macosx-monitor new-monitor
18         dup [ enqueue-notifications ] curry
19         path 1array 0 0 <event-stream> >>handle
20     ] ;
21
22 M: macosx-monitor dispose
23     handle>> dispose ;
24
25 macosx set-io-backend