epoll working on linux

db4
Erik Charlebois 2011-05-15 01:11:12 -04:00
parent 305dcf1551
commit 013209bd17
2 changed files with 12 additions and 6 deletions

View File

@ -23,7 +23,7 @@ M: epoll-mx dispose* fd>> close-file ;
: make-event ( fd events -- event )
epoll-event <struct>
swap >>events
swap >>fd ;
swap over data>> fd<< ;
:: do-epoll-ctl ( fd mx what events -- )
mx fd>> what fd fd events make-event epoll_ctl io-error ;
@ -55,7 +55,7 @@ M: epoll-mx remove-output-callbacks ( fd mx -- seq )
epoll_wait multiplexer-error ;
: handle-event ( event mx -- )
[ fd>> ] dip
[ data>> fd>> ] dip
[ EPOLLIN EPOLLOUT bitor do-epoll-del ]
[ input-available ] [ output-available ] 2tri ;

View File

@ -1,14 +1,19 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
IN: unix.linux.epoll
USING: alien.c-types alien.syntax classes.struct math ;
USING: alien.c-types alien.syntax classes.struct math unix.types ;
FUNCTION: int epoll_create ( int size ) ;
UNION-STRUCT: epoll-data
{ ptr void* }
{ fd int }
{ u32 uint32_t }
{ u64 uint64_t } ;
STRUCT: epoll-event
{ events uint }
{ fd uint }
{ padding uint } ;
{ events uint32_t }
{ data epoll-data } ;
FUNCTION: int epoll_ctl ( int epfd, int op, int fd, epoll-event* event ) ;
@ -28,5 +33,6 @@ CONSTANT: EPOLLWRBAND HEX: 200
CONSTANT: EPOLLMSG HEX: 400
CONSTANT: EPOLLERR HEX: 008
CONSTANT: EPOLLHUP HEX: 010
CONSTANT: EPOLLRDHUP HEX: 2000
: EPOLLONESHOT ( -- n ) 30 2^ ; inline
: EPOLLET ( -- n ) 31 2^ ; inline