 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.backend kernel continuations namespaces sequences
-assocs hashtables sorting arrays threads boxes ;
+assocs hashtables sorting arrays threads boxes io.timeouts ;
 IN: io.monitors
 
 <PRIVATE

: notify-callback ( simple-monitor -- )
    simple-monitor-callback ?box [ resume ] [ drop ] if ;

M: simple-monitor fill-queue ( monitor -- )
    [ swap simple-monitor-callback >box ]
    "monitor" suspend drop
    check-monitor ;

M: simple-monitor dispose ( monitor -- )


! Simple monitor; used on Linux and Mac OS X. On Windows,
! monitors are full-fledged ports.
TUPLE: simple-monitor handle callback timeout ;

M: simple-monitor timeout simple-monitor-timeout ;

M: simple-monitor set-timeout set-simple-monitor-timeout ;

: <simple-monitor> ( handle -- simple-monitor )
    f (monitor) <box> {
